Fix bun patch with workspaces and scoped packages (#12022)

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
This commit is contained in:
Zack Radisic
2024-06-21 14:16:14 -07:00
committed by GitHub
parent 36fbad3709
commit 00f9410d92
3 changed files with 249 additions and 24 deletions

View File

@@ -131,14 +131,19 @@ pub fn indexOfAny16(self: []const u16, comptime str: anytype) ?OptionalUsize {
return null;
}
pub inline fn containsComptime(self: string, comptime str: string) bool {
var remain = self;
if (comptime str.len == 0) @compileError("Don't call this with an empty string plz.");
const start = std.mem.indexOfScalar(u8, self, str[0]) orelse return false;
var remain = self[start..];
const Int = std.meta.Int(.unsigned, str.len * 8);
while (remain.len >= comptime str.len) {
if (@as(Int, @bitCast(remain.ptr[0..str.len].*)) == @as(Int, @bitCast(str.ptr[0..str.len].*))) {
return true;
}
remain = remain[str.len..];
const next_start = std.mem.indexOfScalar(u8, remain[1..], str[0]) orelse return false;
remain = remain[1 + next_start ..];
}
return false;