perf(kit, schema, nuxt): rework startsWith to direct index#24744
Merged
perf(kit, schema, nuxt): rework startsWith to direct index#24744
Conversation
|
|
8 tasks
danielroe
approved these changes
Dec 14, 2023
Contributor
Author
|
Making this a draft too to make as many changes as possible. How many characters would you say would be a fair tradeoff between readability and performance? I don't mind simply adding clear comments above each change so that even newcomers would understand 10 character checks, and allow for maximal speed and efficiency. |
Contributor
Author
|
I do believe this is all of it, I had to test it very thoroughly, so far I have gotten reliable consistent results (in favor of this PR's method) with up to 2 characters. Of course, I will continue testing to see if this can be improved further. |
danielroe
approved these changes
Dec 29, 2023
Merged
9 tasks
9 tasks
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.
🔗 Linked issue
❓ Type of change
📚 Description
JS's startWith is known to have a performance downgrade compared to traditional character checking (you can see more here how vite also substituted those). And indeed, the performance increase is very much noticeable (~20% increase in performance in single character checks and ~15% increase in performance from starting 2 characters, increasing further as more characters are introduced).
Benchmark results:
Now, I know this hurts readability a bit, which is why to make a reasonable tradeoff (if you guys would like to), it is possible to only substitue for single character and double character check, and keep the rest with startsWith. I am curious to hear your opinion on how many characters you would like to substitue (do note that
startsWithwith 10 characters would be many times slower than===with 10 characters)📝 Checklist