Skip to content

Commit a19ecf3

Browse files
committed
Use a local variable in the hot loop
1 parent ec9c7d3 commit a19ecf3

4 files changed

Lines changed: 134 additions & 74 deletions

File tree

src/chunk.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ class Chunk {
7777
size_t disassemble(std::ostream& os, size_t offset,
7878
std::string_view fn_name) const;
7979

80+
// Exposes internals -- for VM use.
81+
uint8_t* location_at(size_t offset) { return code.data() + offset; }
82+
uint8_t* begin_location() { return code.data(); }
83+
uint8_t* end_location() { return code.data() + code.size(); }
84+
8085
private:
8186
// NOTE: std::vector will resize itself automatically when push_back needs
8287
// it. It has two different notions: size() is the number of elements stored,

0 commit comments

Comments
 (0)