Skip to content

Commit

Permalink
remove most of the need for must_draw_infobox()
Browse files Browse the repository at this point in the history
  • Loading branch information
fohristiwhirl committed Jul 3, 2019
1 parent 5f666ce commit a3359c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 8 additions & 3 deletions 80_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {

Expand Down Expand Up @@ -275,23 +276,27 @@ 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;
}
}
}
}

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 = [];

Expand Down
4 changes: 0 additions & 4 deletions 95_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,21 +641,18 @@ 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();
};

renderer.escape = function() { // Set things into a clean state.
this.hide_pgn_chooser();
this.hide_promotiontable();
this.set_active_square(null);
this.info_handler.must_draw_infobox();
};

renderer.toggle_debug_css = function() {
Expand Down Expand Up @@ -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.
};

Expand Down

0 comments on commit a3359c8

Please sign in to comment.