website: parse playground snippets once per run - #402
Merged
Conversation
LuaSandbox.eval/3 parsed every snippet twice: once via Lua.parse_chunk/1 for the bytecode pane and again inside Lua.eval!/2. Reuse the compiled chunk for evaluation; a parse failure still falls through to eval!/2 on the source so the CompilerException error path is unchanged.
Merged
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.
What
LuaSandbox.eval/3parsed every playground snippet twice: once viaLua.parse_chunk/1to build the bytecode pane, and again insideLua.eval!/2. This reuses the compiled chunk for evaluation.Why
Saves a full parse+compile per playground run — up to ~83µs on the metatables example snippet at current parse costs (and still the entire front-end cost once the lexer/compiler perf PRs land). Part of the sub-millisecond playground effort alongside #398–#401.
Behavior
Unchanged. A parse failure falls through to
Lua.eval!/2on the raw source, so theCompilerExceptionerror path (and its formatted messages) is exactly as before. All 52 website tests pass.