[EuiIcon] Improve data URI type performance#5751
Merged
thompsongl merged 6 commits intoelastic:mainfrom Mar 29, 2022
Merged
Conversation
cee-chen
reviewed
Mar 29, 2022
cee-chen
approved these changes
Mar 29, 2022
Contributor
cee-chen
left a comment
There was a problem hiding this comment.
[optional / can be done in a follow-up PR] it would be awesome to write a quick set of unit tests (should be 4-5 cases?) for the new util, but only if we have time / are waiting around for the Kibana PR to merge! if not we can add it in a follow-up PR
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5751/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #5741
Running an "ends with" regex on a large string (such as a image data URI) takes a long time
Before
So using alternative string search methods help immensely
After
We could use
indexOfinstead ofendsWith, but there's extra logic involved to prevent-1matches. We're using the fastest method to bypass additional parsing of data URIs so I'm less concerned with perf after that point.endsWithprovides a good bump compared to the regex (.1ms vs 2ms for URL strings).Also added a data URI example to the docs.
Checklist