diff options
| author | 2023-06-21 23:38:18 -0700 | |
|---|---|---|
| committer | 2023-06-21 23:38:18 -0700 | |
| commit | 5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f (patch) | |
| tree | 97f669a178e60772038751d690c3e298a63557b2 /src/url.zig | |
| parent | bfb322d618a3f0e9618d311ae69016fe7a08e771 (diff) | |
| download | bun-5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f.tar.gz bun-5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f.tar.zst bun-5fa13625a1ca0ea1a3a1c5bb86d0880dcfac349f.zip | |
upgrade zig to `v0.11.0-dev.3737+9eb008717` (#3374)
* progress
* finish `@memset/@memcpy` update
* Update build.zig
* change `@enumToInt` to `@intFromEnum` and friends
* update zig versions
* it was 1
* add link to issue
* add `compileError` reminder
* fix merge
* format
* upgrade to llvm 16
* Revert "upgrade to llvm 16"
This reverts commit cc930ceb1c5b4db9614a7638596948f704544ab8.
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to '')
| -rw-r--r-- | src/url.zig | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/url.zig b/src/url.zig index d0fcdab38..66c4ff015 100644 --- a/src/url.zig +++ b/src/url.zig @@ -275,8 +275,8 @@ pub const URL = struct { if (base.len > path_offset and base[path_offset] == '/' and offset > 0) { if (url.search.len > 0) { - url.pathname = base[path_offset..std.math.min( - std.math.min(offset + url.search.len, base.len), + url.pathname = base[path_offset..@min( + @min(offset + url.search.len, base.len), hash_offset, )]; } else if (hash_offset < std.math.maxInt(u32)) { @@ -289,8 +289,8 @@ pub const URL = struct { if (url.path.len > 1) { const trimmed = std.mem.trim(u8, url.path, "/"); if (trimmed.len > 1) { - url.path = url.path[std.math.min( - std.math.max(@ptrToInt(trimmed.ptr) - @ptrToInt(url.path.ptr), 1) - 1, + url.path = url.path[@min( + @max(@intFromPtr(trimmed.ptr) - @intFromPtr(url.path.ptr), 1) - 1, hash_offset, )..]; } else { @@ -542,12 +542,12 @@ pub const QueryStringMap = struct { } pub fn getIndex(this: *const QueryStringMap, input: string) ?usize { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); return std.mem.indexOfScalar(u64, this.list.items(.name_hash), hash); } pub fn get(this: *const QueryStringMap, input: string) ?string { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); const _slice = this.list.slice(); const i = std.mem.indexOfScalar(u64, _slice.items(.name_hash), hash) orelse return null; return this.str(_slice.items(.value)[i]); @@ -558,7 +558,7 @@ pub const QueryStringMap = struct { } pub fn getAll(this: *const QueryStringMap, input: string, target: []string) usize { - const hash = std.hash.Wyhash.hash(0, input); + const hash = bun.hash(input); const _slice = this.list.slice(); return @call(.always_inline, getAllWithHashFromOffset, .{ this, target, hash, 0, _slice }); } @@ -638,7 +638,7 @@ pub const QueryStringMap = struct { try writer.writeAll(name_slice); buf_writer_pos += @truncate(u32, name_slice.len); - var name_hash: u64 = std.hash.Wyhash.hash(0, name_slice); + var name_hash: u64 = bun.hash(name_slice); value.length = PercentEncoding.decode(Writer, writer, result.rawValue(scanner.pathname.pathname)) catch continue; value.offset = buf_writer_pos; @@ -659,9 +659,9 @@ pub const QueryStringMap = struct { name.length = PercentEncoding.decode(Writer, writer, scanner.query.query_string[name.offset..][0..name.length]) catch continue; name.offset = buf_writer_pos; buf_writer_pos += name.length; - name_hash = std.hash.Wyhash.hash(0, buf.items[name.offset..][0..name.length]); + name_hash = bun.hash(buf.items[name.offset..][0..name.length]); } else { - name_hash = std.hash.Wyhash.hash(0, result.rawName(scanner.query.query_string)); + name_hash = bun.hash(result.rawName(scanner.query.query_string)); if (std.mem.indexOfScalar(u64, list_slice.items(.name_hash), name_hash)) |index| { // query string parameters should not override route parameters @@ -726,7 +726,7 @@ pub const QueryStringMap = struct { var name = result.name; var value = result.value; - const name_hash: u64 = std.hash.Wyhash.hash(0, result.rawName(query_string)); + const name_hash: u64 = bun.hash(result.rawName(query_string)); list.appendAssumeCapacity(Param{ .name = name, .value = value, .name_hash = name_hash }); } @@ -752,9 +752,9 @@ pub const QueryStringMap = struct { name.length = PercentEncoding.decode(Writer, writer, query_string[name.offset..][0..name.length]) catch continue; name.offset = buf_writer_pos; buf_writer_pos += name.length; - name_hash = std.hash.Wyhash.hash(0, buf.items[name.offset..][0..name.length]); + name_hash = bun.hash(buf.items[name.offset..][0..name.length]); } else { - name_hash = std.hash.Wyhash.hash(0, result.rawName(query_string)); + name_hash = bun.hash(result.rawName(query_string)); if (std.mem.indexOfScalar(u64, list_slice.items(.name_hash), name_hash)) |index| { name = list_slice.items(.name)[index]; } else { @@ -1126,7 +1126,7 @@ pub const FormData = struct { break; }, '\\' => { - i += @boolToInt(field_value.len > i + 1 and field_value[i + 1] == '"'); + i += @intFromBool(field_value.len > i + 1 and field_value[i + 1] == '"'); }, // the spec requires a end quote, but some browsers don't send it else => {}, @@ -1434,7 +1434,7 @@ test "Scanner.next - % encoded" { test "PercentEncoding.decode" { var buffer: [4096]u8 = undefined; - std.mem.set(u8, &buffer, 0); + @memset(&buffer, 0); var stream = std.io.fixedBufferStream(&buffer); var writer = stream.writer(); |
