aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-18 10:47:42 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-18 10:47:42 -0700
commitfdb7940c4e435a5b7f5a368f4168d748baf6b5b6 (patch)
treeee23b0ee654cb7ff9307ccc1db961fed444e01f6 /src/string_immutable.zig
parent873f615358b78f913b3f8fe6adda47da7e6e57ac (diff)
downloadbun-fdb7940c4e435a5b7f5a368f4168d748baf6b5b6.tar.gz
bun-fdb7940c4e435a5b7f5a368f4168d748baf6b5b6.tar.zst
bun-fdb7940c4e435a5b7f5a368f4168d748baf6b5b6.zip
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>
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig10
1 files changed, 9 insertions, 1 deletions
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 {