Don't `match` twice when reading instructions from bytecode
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Currently `read_instruction` matches on the current byte as an op code, then returns an `Instruction` enum the caller must match on again.
It might be more efficient to let the caller match on the op code, then have `ChunkCursor` provide methods like `read_constant_instruction` which the caller can call directly, reducing the two matches to one.
It's unclear if this will actually make an improvement, so we'll need to run some benchmarks to see.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating read_instruction, ChunkCursor, and the Instruction enum in the bytecode-reading path. Benchmark the current double-match behavior against the proposed caller-side opcode handling, and consider the work complete when the results establish whether the refactor improves performance and the chosen approach is covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100