overlookmotel
c0e9d7eb77
refactor(codegen)!: Codegen::into_source_text consume Codegen ( #6539 )
...
Breaking change. `Codegen::into_source_text` consume `Codegen`, instead of taking the `CodeBuffer` and substituting an empty one.
Keeping the `Codegen` alive seems unintuitive, as its state is then out of sync. Consuming the `CodeBuffer` is also marginally cheaper.
2024-10-14 01:09:03 +00:00
overlookmotel
7e909a7e6c
docs(codegen): fix example for CodeBuffer::print_ascii_bytes ( #6535 )
...
Fix example and add a test.
2024-10-14 01:09:02 +00:00
overlookmotel
77f3a1a9dd
perf(codegen): check last char with byte methods ( #6509 )
...
When checking what last char in buffer is, avoid calculating a `char` when only comparing to an ASCII char (byte) anyway.
2024-10-14 01:09:02 +00:00
overlookmotel
18b68ff90e
perf(codegen): optimize CodeBuffer::print_ascii_byte ( #6516 )
...
Optimize `CodeBuffer`'s `print_byte_unchecked` and `print_ascii_byte` methods by making a fast path for when the buffer has sufficient capacity to be pushed to without growing.
As discussed in https://github.com/oxc-project/oxc/pull/6148#issuecomment-2381635390
2024-10-14 01:09:01 +00:00
overlookmotel
51fc63da45
refactor(codegen): rename CodeBuffer::print_bytes_unchecked method ( #6517 )
2024-10-13 13:14:49 +00:00
overlookmotel
235d357600
docs(codegen): improve doc comments for CodeBuffer ( #6511 )
2024-10-13 12:21:39 +00:00
overlookmotel
e7f3e28076
refactor(codegen): rename var in CodeBuffer ( #6510 )
2024-10-13 11:58:39 +00:00
overlookmotel
1bbd383d0f
refactor(codegen): rename CodeBuffer::print_ascii_bytes method ( #6507 )
...
Pure refactor.
2024-10-13 11:19:09 +00:00
overlookmotel
cd9fe9ec03
refactor(codegen): rename vars in CodeBuffer methods ( #6506 )
...
Pure refactor. Consistently use `byte` for bytes, and `ch` for `char`s.
2024-10-13 11:10:10 +00:00
overlookmotel
c8fa2eb17a
docs(codegen): correct and reformat doc comments for CodeBuffer ( #6504 )
...
Comment about `take_source_text` was erroneous. Clean up and reformat other doc comments.
2024-10-13 11:10:09 +00:00
overlookmotel
fc536a5648
refactor(codegen): inline CodeBuffer methods ( #6501 )
...
These methods are all either trivial, or delegate to another method.
2024-10-13 10:55:07 +00:00
overlookmotel
40d1ee4588
docs(codegen): fix and reformat CodeBuffer examples ( #6499 )
...
Fix examples which would not compile.
2024-10-13 10:49:37 +00:00
overlookmotel
74206204dd
refactor(codegen): add CodeBuffer::as_bytes method ( #6498 )
...
`as_bytes` is clearer than `as_ref` (what kind of ref?)
2024-10-13 10:05:10 +00:00
overlookmotel
d816b0bd0e
test(codegen): add test for CodeBuffer::print_byte_unchecked ( #6497 )
...
Add test, and rename the rest of the test functions for `CodeBuffer`.
2024-10-13 09:51:50 +00:00
overlookmotel
8ae174bd36
refactor(codegen): rename CodeBuffer::print_byte_unchecked method ( #6496 )
...
Pure refactor. `*_unchecked` is the conventional name for unsafe methods, not `*_unsafe`.
2024-10-13 09:51:49 +00:00
overlookmotel
5843e01bed
refactor(codegen): shorten CodeBuffer::take_source_text ( #6495 )
...
Pure refactor.
2024-10-13 09:51:47 +00:00
overlookmotel
951def6e35
refactor(codegen): clarify safety comments in CodeBuffer ( #6494 )
2024-10-13 09:36:40 +00:00
overlookmotel
84a51ee576
refactor(codegen): rename vars in CodeBuffer ( #6493 )
...
Pure refactor. Just rename vars.
2024-10-13 09:36:39 +00:00
overlookmotel
05bd616d88
refactor(codegen): add line break ( #6492 )
2024-10-13 09:27:42 +00:00
DonIsaac
204bf5533e
refactor(codegen): add CodeBuffer to fix soundness hole ( #6148 )
...
# What This PR Does
Adds `CodeBuffer`, a simple wrapper over a `Vec<u8>` with a protective and reduced API for upholding UTF-8 validity guarantees. Closes #6147 .
Note that this struct is actually quite small. Most of the added lines are doc comments.
2024-10-13 09:14:48 +00:00