Skip to content

Commit

Permalink
Parser: move char literal array resize out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Oct 10, 2023
1 parent a52396a commit 16c56e7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7661,9 +7661,10 @@ fn charLiteral(p: *Parser) Error!Result {
.utf8_text => |view| {
var it = view.iterator();
var max_codepoint: u21 = 0;
try chars.ensureUnusedCapacity(view.bytes.len);
while (it.nextCodepoint()) |c| {
max_codepoint = @max(max_codepoint, c);
try chars.append(c);
chars.appendAssumeCapacity(c);
}
if (max_codepoint > char_kind.maxCodepoint(p.comp)) {
char_literal_parser.err(.char_too_large, .{ .none = {} });
Expand Down

0 comments on commit 16c56e7

Please sign in to comment.