Commit 2b3df5a
Remove Buffer; store path instead of source text on Source
Ruby's RBS::Buffer exists because RBS::Location is lazy: it holds a
reference to the buffer and slices out text on demand for #source and
pos_to_loc. The Rust port mirrored that shape, but the architecture
underneath it isn't lazy — AstConverter eagerly interns or copies
every semantically relevant string (names, comments, annotations,
literals) at conversion time, and LocationRange is a plain 4x u32
offset Copy type with no reference back into the source. There is no
deferred slicing step left that would ever need the buffer, so
nothing in the crate calls Buffer::content() after parse_one()
returns — it's a write-only store.
Keeping it anyway means holding the full text of every loaded file
for the Environment's lifetime for no benefit: ~4.3MB across core +
stdlib alone, more with gems, growing for as long as the Environment
lives.
Source.buffer: Buffer is replaced with Source.path: PathBuf, keeping
just enough to identify the file for error reporting. parse_one() no
longer moves `content` into a Buffer, so the explicit drop(signature)
that used to be needed to end its borrow first is gone too.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 0b70e05 commit 2b3df5a
5 files changed
Lines changed: 3 additions & 31 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
175 | 174 | | |
176 | 175 | | |
177 | 176 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | 177 | | |
182 | 178 | | |
183 | | - | |
| 179 | + | |
184 | 180 | | |
185 | 181 | | |
186 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
0 commit comments