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.
Problem: when an editor contains many list items that are represented by the same image marker, there is a substantial amount in the layout pass spent resizing the image to the given size.
Solution: since the markers and sizes are the same for list items, we can cache the resized image and reuse it for successive calls. In some cases the number of calls to resize images went from ~7700 to just 4.
The implementation uses a Dictionary to store a cache for each image, and the cache is keyed by the size. I tried creating a cache with a single key derived from the image and size, however the string interpolation turned out to be more expensive than this approach.
I profiled the rendering before/after the change and here are the results:
Before:
After: