From d276e5be454e7b00a9abfc6e0e764bf83b44b116 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 25 Apr 2020 18:04:42 +0530 Subject: [PATCH] Do not update toc anchor map repeatedly --- src/pyj/read_book/iframe.pyj | 4 +++- src/pyj/read_book/toc.pyj | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 53e6622e90..668553fcff 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -30,7 +30,8 @@ from read_book.flow_mode import ( from read_book.footnotes import is_footnote_link from read_book.globals import ( annot_id_uuid_map, clear_annot_id_uuid_map, current_book, current_layout_mode, - current_spine_item, runtime, set_boss, set_current_spine_item, set_layout_mode + current_spine_item, runtime, set_boss, set_current_spine_item, set_layout_mode, + set_toc_anchor_map ) from read_book.mathjax import apply_mathjax from read_book.paged_mode import ( @@ -202,6 +203,7 @@ class IframeBoss: self.content_ready = False clear_annot_id_uuid_map() reset_highlight_counter() + set_toc_anchor_map() self.replace_history_on_next_cfi_update = True self.book = current_book.book = data.book self.reference_mode_enabled = data.reference_mode_enabled diff --git a/src/pyj/read_book/toc.pyj b/src/pyj/read_book/toc.pyj index 3b99d4445b..3d647653df 100644 --- a/src/pyj/read_book/toc.pyj +++ b/src/pyj/read_book/toc.pyj @@ -181,7 +181,7 @@ def current_toc_anchor_map(tam, anchor_funcs): # stable sort by position in document anchors.sort(def (a, b): return anchor_funcs.cmp(am[a], am[b]) or (pos_map[a] - pos_map[b]);) - current_map = {'layout_mode': current_layout_mode, 'width': scroll_viewport.width(), 'height': scroll_viewport.height(), 'pos_map': am, 'sorted_anchors':anchors} + current_map = {'layout_mode': current_layout_mode(), 'width': scroll_viewport.width(), 'height': scroll_viewport.height(), 'pos_map': am, 'sorted_anchors':anchors} set_toc_anchor_map(current_map) return current_map