diff options
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r-- | src/string_immutable.zig | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 6a82e0dfd..b14d9fc5d 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1063,7 +1063,6 @@ pub fn copyLatin1IntoASCII(dest: []u8, src: []const u8) void { /// If there are no non-ascii characters, this returns null /// This is intended to be used for strings that go to JavaScript pub fn toUTF16Alloc(allocator: std.mem.Allocator, bytes: []const u8, comptime fail_if_invalid: bool) !?[]u16 { - var first_non_ascii: ?u32 = null; var output_: ?std.ArrayList(u16) = null; if (comptime bun.FeatureFlags.use_simdutf) { @@ -1092,7 +1091,6 @@ pub fn toUTF16Alloc(allocator: std.mem.Allocator, bytes: []const u8, comptime fa return error.InvalidByteSequence; } - first_non_ascii = 0; output_ = .{ .items = out[0..0], .capacity = out.len, @@ -1104,14 +1102,13 @@ pub fn toUTF16Alloc(allocator: std.mem.Allocator, bytes: []const u8, comptime fa } } - if (first_non_ascii orelse strings.firstNonASCII(bytes)) |i| { + if (strings.firstNonASCII(bytes)) |i| { const ascii = bytes[0..i]; const chunk = bytes[i..]; var output = output_ orelse try std.ArrayList(u16).initCapacity(allocator, ascii.len + 2); errdefer output.deinit(); output.items.len = ascii.len; - if (first_non_ascii == null) - strings.copyU8IntoU16(output.items, ascii); + strings.copyU8IntoU16(output.items, ascii); var remaining = chunk; |