Optimize line breaking by limiting scanning
The LazyLineBreakIterator::IsBreakable method works by comparing a given position with the next following breakable position. This is inefficient as well as unnecessary. Instead limit the scan to the given position + 1 as that still allows comparsion of the supplied and the resulting value. Similarly, the LazyLineBreakIterator::NextBreakOpportunity method always scans until the end of the string, even if that is past the threshold of the section of the string processed. By introducing a version that takes a length parameter, and changing ShapingLineBreaker::ShapeLine to use it instead of the unbounded one, the scope of the forward scan can therefor be limited to the length of the line being processed. These two changes dramatically speed up line breaking both in legacy and LayoutNG, especially for large text blocks with few break opportunities. Test: perf_tests/paint/appending-text.html, perf_tests/layout/long-line-nowrap.html Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng Change-Id: I7a4186510f4451219dd026e8f3ab1ed0c86fa3c2 Reviewed-on: https://chromium-review.googlesource.com/1150853Reviewed-by:Stefan Zager <szager@chromium.org> Commit-Queue: Emil A Eklund <eae@chromium.org> Cr-Commit-Position: refs/heads/master@{#578437}
Showing
Please register or sign in to comment