From 6a69c971d46bf4cc59221c8adcd41d12b04e5a14 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 26 May 2021 18:15:21 -0700 Subject: Skip slow path Former-commit-id: 96a33924fb1d0cf0716a6123660500146b9588ee --- src/js_lexer.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/js_lexer.zig b/src/js_lexer.zig index 05e76e77c..1ee2ae084 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -495,11 +495,12 @@ pub const Lexer = struct { switch (lexer.code_point) { '\\' => { try lexer.step(); - // Skip slow path for \n in a string literal - // This is pretty common, shows up in e.g. React - // Example code: array.split("\n") - // We don't need to decode as UTF16 for that. We know it's just a newline char. - needs_slow_path = lexer.code_point != 'n'; + + // Skip slow path for a handful of common escaped characters that don't need UTf16 handling + needs_slow_path = switch (lexer.code_point) { + 'n', '`', '\'', '0', '"' => false, + else => true, + }; // Handle Windows CRLF if (lexer.code_point == '\r' and lexer.json_options != null) { -- cgit v1.2.3