From fdb7940c4e435a5b7f5a368f4168d748baf6b5b6 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 18 Jun 2023 10:47:42 -0700 Subject: Fix a bunch of bugs (#3352) * Fix a bunch of bugs * undo that one * Fix crash in readdir() * woops * woops * Add comment * :scissors: * Make `readlink()` and `realpath` use much less memory * Update BunString.cpp * woopsie * Unnecessary * Don't commit these --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/string_immutable.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/string_immutable.zig') diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 8aaa6f8e8..9e069bb99 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -74,6 +74,10 @@ pub inline fn containsComptime(self: string, comptime str: string) bool { } pub const includes = contains; +pub fn inMapCaseInsensitive(self: string, comptime ComptimeStringMap: anytype) ?ComptimeStringMap.Value { + return bun.String.static(self).inMapCaseInsensitive(ComptimeStringMap); +} + pub inline fn containsAny(in: anytype, target: string) bool { for (in) |str| if (contains(if (@TypeOf(str) == u8) &[1]u8{str} else bun.span(str), target)) return true; return false; @@ -1071,7 +1075,11 @@ pub fn index(self: string, str: string) i32 { } pub fn eqlUtf16(comptime self: string, other: []const u16) bool { - return std.mem.eql(u16, toUTF16Literal(self), other); + if (self.len != other.len) return false; + + if (self.len == 0) return true; + + return bun.C.memcmp(bun.cast([*]const u8, self.ptr), bun.cast([*]const u8, other.ptr), self.len * @sizeOf(u16)) == 0; } pub fn toUTF8Alloc(allocator: std.mem.Allocator, js: []const u16) !string { -- cgit v1.2.3