mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
Use Highway SIMD (#19134)
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com> Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -3563,26 +3563,10 @@ var stderr_mutex = bun.Mutex{};
|
||||
|
||||
pub fn hasEqSign(str: []const u8) ?u32 {
|
||||
if (isAllAscii(str)) {
|
||||
if (str.len < 16)
|
||||
return hasEqSignAsciiSlow(str);
|
||||
|
||||
const needles: @Vector(16, u8) = @splat('=');
|
||||
|
||||
var i: u32 = 0;
|
||||
while (i + 16 <= str.len) : (i += 16) {
|
||||
const haystack = str[i..][0..16].*;
|
||||
const result = haystack == needles;
|
||||
|
||||
if (std.simd.firstTrue(result)) |idx| {
|
||||
return @intCast(i + idx);
|
||||
}
|
||||
}
|
||||
|
||||
return i + (hasEqSignAsciiSlow(str[i..]) orelse return null);
|
||||
return bun.strings.indexOfChar(str, '=');
|
||||
}
|
||||
|
||||
// TODO actually i think that this can also use the simd stuff
|
||||
|
||||
var iter = CodepointIterator.init(str);
|
||||
var cursor = CodepointIterator.Cursor{};
|
||||
while (iter.next(&cursor)) {
|
||||
@@ -3594,11 +3578,6 @@ pub fn hasEqSign(str: []const u8) ?u32 {
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn hasEqSignAsciiSlow(str: []const u8) ?u32 {
|
||||
for (str, 0..) |c, i| if (c == '=') return @intCast(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
pub const CmdEnvIter = struct {
|
||||
env: *const bun.StringArrayHashMap([:0]const u8),
|
||||
iter: bun.StringArrayHashMap([:0]const u8).Iterator,
|
||||
|
||||
Reference in New Issue
Block a user