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.
Optimize
match
with jump tables whenever possible. I want to use two kinds of tables:OPCODE_JUMP_TABLE_RANGE
. Can be used for continuous (or with a little sparsity) ranges of integers (such as enums). For example, from 0 to 10, or from 2 to 12. Instead of doing N comparisons (in the worst case), the jump address is calculated using the value, offset, and size.OPCODE_JUMP_TABLE_BSEARCH
. Can be used to binary search in a constant array sorted at compilation. Suitable when the value is not an integer or the range is very sparse.When using variable patterns, destructuring (and match guards in the future), the old bytecode will be preserved (or the branches will be divided into subgroups in which optimizations can be performed).
TODO
Parser
pass
inmatch
.REDUNDANT_PATTERN
(multiple patterns with a wildcard pattern).match
.Analyzer
==
operator described in GDScript: Unexpected behavior ofmatch
on float variable with integral constants #74462.DUPLICATE_PATTERN
.Codegen, VM, disassembler
OPCODE_JUMP_TABLE_RANGE
andOPCODE_JUMP_TABLE_BSEARCH
.Compiler
match
with jump tables.Miscellaneous
if
-elif
-else
.