aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-26 18:15:21 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-26 18:15:21 -0700
commit6a69c971d46bf4cc59221c8adcd41d12b04e5a14 (patch)
treea55eb8119f2ed1899201ed88c0a7e05a61f32657 /src
parent4a7067a0a2866ce8af2ee26197893079b77526b8 (diff)
downloadbun-6a69c971d46bf4cc59221c8adcd41d12b04e5a14.tar.gz
bun-6a69c971d46bf4cc59221c8adcd41d12b04e5a14.tar.zst
bun-6a69c971d46bf4cc59221c8adcd41d12b04e5a14.zip
Skip slow path
Former-commit-id: 96a33924fb1d0cf0716a6123660500146b9588ee
Diffstat (limited to 'src')
-rw-r--r--src/js_lexer.zig11
1 files changed, 6 insertions, 5 deletions
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) {