Skip to content

Commit e0d70ef

Browse files
committed
refactor(codegen): clarify comments (#12036)
Follow-on after #11782. Clarify comments.
1 parent 22799c3 commit e0d70ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/oxc_codegen/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ impl<'a> Codegen<'a> {
240240
let mut consumed = 0;
241241
let mut i = 0;
242242

243-
// Only check when remaining string has length larger than 8.
243+
// Only check when remaining string has length larger than 8
244244
while i + 8 <= slice.len() {
245245
if is_script_close_tag(&slice[i..i + 8]) {
246246
// Push str up to and including `<`. Skip `/`. Write `\/` instead.
247+
// Skip over `script` - it'll be written in next chunk.
247248
// SAFETY:
248-
// The slice guarantees to be a valid UTF-8 string.
249-
// The consumed index is always pointed to a UTF-8 char boundary.
250-
// Current byte is `<`, a UTF-8 char boundary.
249+
// The slice is guaranteed to be a valid UTF-8 string.
250+
// `consumed` is always on a UTF-8 char boundary.
251+
// `i` is on `<`, so `i + 1` is a UTF-8 char boundary.
251252
unsafe {
252253
self.code.print_bytes_unchecked(&slice[consumed..=i]);
253254
}

0 commit comments

Comments
 (0)