File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
lib/Terminal/Widgets/Viewer Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,16 @@ class Terminal::Widgets::Viewer::Tree
111111 # self.flat-line-cache.map({ $locale.width($_) }).max
112112
113113 # XXXX: HACK while refactoring content model
114+ use Text::MiscUtils::Layout;
115+ state % width-cache ;
116+
114117 my $ debug = + ($ * DEBUG // 0 );
115118 my $ t0 = now;
116- my $ max = self . flat-line-cache. map ({ . [0 ]. text. chars
117- + . [1 ]. text. chars }). max ;
119+ my $ max = self . flat-line-cache. map ({
120+ # Only prefix has low enough cardinality to cache
121+ (% width-cache {. [0 ]. text} // = duospace-width-core(. [0 ]. text, 0 ))
122+ + duospace-width-core(. [1 ]. text, 0 )
123+ }). max ;
118124 note sprintf (" max-line-width: %.3fms (% d elems)" ,
119125 1000 * (now - $ t0 ), @ ! flat-line-cache . elems ) if $ debug ;
120126 $ max
You can’t perform that action at this time.
0 commit comments