mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Fix a bunch of bugs (#3352)
* Fix a bunch of bugs * undo that one * Fix crash in readdir() * woops * woops * Add comment * ✂️ * 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>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user