[mini.snippets] "MiniSnippets.parse" performance improvement. #2499
Closed
Aumnescio
started this conversation in
Show and tell
Replies: 2 comments
|
Yeah, I can reproduce the performance difference with and without using I think it would be safe to just use byte iteration, but need more time to confer and test. However, even the existing approach is usually done together with caching file contents. I am not so keen on introducing custom character byte length logic (and existing tests might have missed something to do with multibyte characters). So if the "just traverse bytes" solution doesn't work out, I'll leave it as is. |
0 replies
|
I think using raw bytes instead of characters when traversing the snippet should be fine indeed. So this should now be how latest |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bit lazy about posting a full issue / PR about this, but want to share. This primarily concerns parsing large'ish snippets. (like 100-200+ lines.) Though the performance impact should affect basically all parsing of snippets. It's just not really so noticeable unless the snippet is a bit larger.
This part of
snippets.luais seemingly very slow. (~375ms to parse the attached sample file snippet.)Alternative version
The code below parses the same snippet in under 5ms. It also passes all the snippets tests.
Usage: just replace the original loop block with this version.
Attachments
NOTE: Github doesn't allow me to upload the file ending in
.lua, so it needs to be renamed. (for example totoml.lua)sample-toml-lua.txt
All reactions