Avoid expensive expression parsing when drawing symbols #8295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this PR, the
drawSymbols
routine had to reparse any icon/text-size property expressions when performingevaluateSizeForZoom
routine. This led to it taking a noticeable time on the main thread.The main goal of the PR (first 3 commits) is to simplify the
sizeData
structure used for it so that it only retains the interpolation factor rather than the whole expression property, making it leaner and completely avoiding the need to parse expressions. On a sample profiling of a Streers-v11 style, it shows roughly 5-10% less time fordrawSymbols
.The last commit just simplifies the code to make it easier to read.
The Paint/LayerSymbol benchmarks don't show any difference because the overhead only appear when using expression-heavy styles such as Streets-v11. We should update our benchmark to reflect the current style spec usage in a separate PR.