From a3359c8d2141fa8ecad9ff60327aeb2ed181574c Mon Sep 17 00:00:00 2001 From: fohristiwhirl Date: Wed, 3 Jul 2019 16:27:43 +0100 Subject: [PATCH] remove most of the need for must_draw_infobox() --- 80_info.js | 11 ++++++++--- 95_renderer.js | 4 ---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/80_info.js b/80_info.js index ac7d49d4..add3e2b3 100644 --- a/80_info.js +++ b/80_info.js @@ -20,6 +20,7 @@ function NewInfoHandler() { ih.last_drawn_version = null; ih.last_drawn_highlight = null; ih.last_drawn_highlight_class = null; + ih.last_drawn_searchmoves = []; ih.clear = function(board) { if (!board) { @@ -223,7 +224,7 @@ function NewInfoHandler() { this.last_drawn_version = null; }; - ih.draw_statusbox = function(leela_should_go, searchmoves = []) { + ih.draw_statusbox = function(leela_should_go, searchmoves) { if (config.search_nodes !== "infinite" && (searchmoves.length === 1)) { @@ -275,16 +276,19 @@ function NewInfoHandler() { highlight_class = "hover_highlight"; } - // We can skip the draw iff: + // We can skip the draw if: // // - The last drawn version matches // - The last drawn highlight matches // - The last drawn highlight class matches + // - The searchmoves match (some possibility of false negatives due to re-ordering, but that's OK) if (this.version === this.last_drawn_version) { if (highlight_move === this.last_drawn_highlight_move) { if (highlight_class === this.last_drawn_highlight_class) { - return; + if (CompareArrays(searchmoves, this.last_drawn_searchmoves)) { + return; + } } } } @@ -292,6 +296,7 @@ function NewInfoHandler() { this.last_drawn_version = this.version; this.last_drawn_highlight_move = highlight_move; this.last_drawn_highlight_class = highlight_class; + this.last_drawn_searchmoves = Array.from(searchmoves); this.info_clickers = []; diff --git a/95_renderer.js b/95_renderer.js index 5a1f81f3..7d2005c6 100644 --- a/95_renderer.js +++ b/95_renderer.js @@ -641,13 +641,11 @@ function NewRenderer() { } this.searchmoves = Object.keys(moveset); - this.info_handler.must_draw_infobox(); this.go_or_halt(); }; renderer.clear_searchmoves = function() { this.searchmoves = []; - this.info_handler.must_draw_infobox(); this.go_or_halt(); }; @@ -655,7 +653,6 @@ function NewRenderer() { this.hide_pgn_chooser(); this.hide_promotiontable(); this.set_active_square(null); - this.info_handler.must_draw_infobox(); }; renderer.toggle_debug_css = function() { @@ -809,7 +806,6 @@ function NewRenderer() { this.searchmoves.push(sm); } - this.info_handler.must_draw_infobox(); this.go_or_halt(); // If we're running, send a new go message with the updated searchmoves. };