DescriptionOptimize SVGTextQuery's character offset ligature adjustment query
For queries that take a code unit to compute some property for (basically
all *OfChar calls), the <start, end> range is mapped to the closest
glyph-boundary to allow queries within ligatures.
This adjustment step is O(N), N=number of glyphs within a text node, and
is performed for each fragment within a text box.
This means that for text boxes with a large number of fragments - and,
consequently, a large number of glyphs - there'll be O(N^2) behavior.
Since the <start, end> range is invariant for most queries, it should
suffice to compute the adjusted range once per text node [1].
The easiest way to achieve this is by adding a simple cache and reuse the
result of an adjustment query (for every fragment in a text box.)
This improves the runtime of the test in the bug from ~13s to ~120ms (or
approximately a factor 100) locally.
[1] This CL however only perform caching per text box in order to minimize
modifications to the actual adjustment code.
BUG=267504
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=176937
Patch Set 1 #
Total comments: 6
Patch Set 2 : Fold *Cached method. #Patch Set 3 : More explicit invalidation. #Messages
Total messages: 7 (0 generated)
|