perf(shiki-monaco): improve tokenizer performance#645
Merged
antfu merged 1 commit intoshikijs:mainfrom Mar 30, 2024
ije:perfs-shiki-monaco
Merged
perf(shiki-monaco): improve tokenizer performance#645antfu merged 1 commit intoshikijs:mainfrom ije:perfs-shiki-monaco
antfu merged 1 commit intoshikijs:mainfrom
ije:perfs-shiki-monaco
Conversation
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #645 +/- ##
=======================================
Coverage 96.31% 96.31%
=======================================
Files 70 70
Lines 5699 5699
Branches 753 753
=======================================
Hits 5489 5489
Misses 205 205
Partials 5 5 ☔ View full report in Codecov by Sentry. |
ije
commented
Mar 29, 2024
| class TokenizerState implements monacoNs.languages.IState { | ||
| constructor( | ||
| private _ruleStack: StateStack, | ||
| public highlighter: ShikiInternal<any, any>, |
Contributor
Author
There was a problem hiding this comment.
we don't need the highlighter field, just use the colsure one
ije
commented
Mar 29, 2024
| return color | ||
| color = color.replace('#', '').toLowerCase() | ||
|
|
||
| color = (color.charCodeAt(0) === 35 ? color.slice(1) : color).toLowerCase() |
Contributor
Author
There was a problem hiding this comment.
this should be faster by checking first char code instead of calling replace
antfu
approved these changes
Mar 29, 2024
diegohaz
referenced
this pull request
in ariakit/ariakit
Apr 13, 2024
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [shiki](https://github.com/shikijs/shiki) ([source](https://github.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`1.2.0` -> `1.3.0`](https://renovatebot.com/diffs/npm/shiki/1.2.0/1.3.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>shikijs/shiki (shiki)</summary> ### [`v1.3.0`](https://github.com/shikijs/shiki/releases/tag/v1.3.0) [Compare Source](https://github.com/shikijs/shiki/compare/v1.2.4...v1.3.0) ##### 🚀 Features - **core**: New `structure: inline` option for `codeToHast` - by [@​antfu](https://github.com/antfu) in [https://github.com/shikijs/shiki/issues/653](https://github.com/shikijs/shiki/issues/653) [<samp>(ae516)</samp>](https://github.com/shikijs/shiki/commit/ae516aec) ##### [View changes on GitHub](https://github.com/shikijs/shiki/compare/v1.2.4...v1.3.0) ### [`v1.2.4`](https://github.com/shikijs/shiki/releases/tag/v1.2.4) [Compare Source](https://github.com/shikijs/shiki/compare/v1.2.3...v1.2.4) *No significant changes* ##### [View changes on GitHub](https://github.com/shikijs/shiki/compare/v1.2.3...v1.2.4) ### [`v1.2.3`](https://github.com/shikijs/shiki/releases/tag/v1.2.3) [Compare Source](https://github.com/shikijs/shiki/compare/v1.2.2...v1.2.3) ##### 🐞 Bug Fixes - `colorReplacements` also for `bg` and `fg`, close [#​641](https://github.com/shikijs/shiki/issues/641) - by [@​antfu](https://github.com/antfu) in [https://github.com/shikijs/shiki/issues/641](https://github.com/shikijs/shiki/issues/641) [<samp>(bb47a)</samp>](https://github.com/shikijs/shiki/commit/bb47a846) ##### [View changes on GitHub](https://github.com/shikijs/shiki/compare/v1.2.2...v1.2.3) ### [`v1.2.2`](https://github.com/shikijs/shiki/releases/tag/v1.2.2) [Compare Source](https://github.com/shikijs/shiki/compare/v1.2.1...v1.2.2) ##### 🚀 Features - Update deps, new `tsv` grammar - by [@​antfu](https://github.com/antfu) [<samp>(a7ca7)</samp>](https://github.com/shikijs/shiki/commit/a7ca7c32) ##### 🐞 Bug Fixes - **monaco**: Typo on interface - by [@​ije](https://github.com/ije) in [https://github.com/shikijs/shiki/issues/644](https://github.com/shikijs/shiki/issues/644) [<samp>(1fc70)</samp>](https://github.com/shikijs/shiki/commit/1fc70bd3) ##### 🏎 Performance - **shiki-monaco**: Improve tokenizer performance - by [@​ije](https://github.com/ije) in [https://github.com/shikijs/shiki/issues/645](https://github.com/shikijs/shiki/issues/645) [<samp>(069e0)</samp>](https://github.com/shikijs/shiki/commit/069e0be7) ##### [View changes on GitHub](https://github.com/shikijs/shiki/compare/v1.2.1...v1.2.2) ### [`v1.2.1`](https://github.com/shikijs/shiki/releases/tag/v1.2.1) [Compare Source](https://github.com/shikijs/shiki/compare/v1.2.0...v1.2.1) ##### 🐞 Bug Fixes - **vitepress-twoslash**: Pass `options.twoslashOptions` to `createTwoslasher` - by [@​sapphi-red](https://github.com/sapphi-red) in [https://github.com/shikijs/shiki/issues/637](https://github.com/shikijs/shiki/issues/637) [<samp>(75832)</samp>](https://github.com/shikijs/shiki/commit/75832e13) ##### [View changes on GitHub](https://github.com/shikijs/shiki/compare/v1.2.0...v1.2.1) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ariakit/ariakit). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 task
This was referenced May 18, 2024
This was referenced May 25, 2024
This was referenced Jun 2, 2024
This was referenced Jun 9, 2024
1 task
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.
Description
The
tokenizemethod of current implement computescolorMapandcolorToScopeMapevery time when it's called.This patch moved the
colorMapout of thetokenizemethod, only re-computes whensetThemeis called.no testing, the code works fine in my wip editor:
Screen.Recording.2024-03-30.at.00.26.13.mov