aboutsummaryrefslogtreecommitdiff
path: root/src/string_mutable.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-20 01:43:40 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-20 01:43:40 -0800
commite41d7a0bd5f81d380868b07a7621195fcadbd7af (patch)
tree45dfe79be475abf98e6f0302cec8d46639b51902 /src/string_mutable.zig
parentb745ae26677083ba6fe36bb72441ce338e881a0e (diff)
downloadbun-e41d7a0bd5f81d380868b07a7621195fcadbd7af.tar.gz
bun-e41d7a0bd5f81d380868b07a7621195fcadbd7af.tar.zst
bun-e41d7a0bd5f81d380868b07a7621195fcadbd7af.zip
[fetch] Add optimization for chunked encoding
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r--src/string_mutable.zig14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig
index 9d89ea9db..a9f528cc0 100644
--- a/src/string_mutable.zig
+++ b/src/string_mutable.zig
@@ -30,18 +30,8 @@ pub const MutableString = struct {
}
}
- pub fn owns(this: *const MutableString, buffer: []const u8) bool {
- if (this.list.capacity < buffer.len) {
- return false;
- }
-
- if (@ptrToInt(this.list.items.ptr) <= @ptrToInt(buffer.ptr) and
- @ptrToInt(buffer.ptr) + buffer.len <= @ptrToInt(this.list.items.ptr) + this.list.capacity)
- {
- return true;
- }
-
- return false;
+ pub fn owns(this: *const MutableString, slice: []const u8) bool {
+ return @import("./global.zig").isSliceInBuffer(slice, this.list.items.ptr[0..this.list.capacity]);
}
pub fn growIfNeeded(self: *MutableString, amount: usize) !void {