mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
Even More Comments
This commit is contained in:
@@ -136,6 +136,7 @@ pub const ZigString = extern struct {
|
||||
return @intToPtr([*]u8, @ptrToInt(this.ptr))[0..this.len];
|
||||
}
|
||||
|
||||
/// Does nothing if the slice is not allocated
|
||||
pub fn deinit(this: *const Slice) void {
|
||||
if (!this.allocated) {
|
||||
return;
|
||||
|
||||
@@ -190,10 +190,9 @@ pub const Encoding = enum(u8) {
|
||||
const Eight = strings.ExactSizeMatcher(8);
|
||||
/// Caller must verify the value is a string
|
||||
pub fn fromStringValue(value: JSC.JSValue, global: *JSC.JSGlobalObject) ?Encoding {
|
||||
var str = JSC.ZigString.Empty;
|
||||
value.toZigString(&str, global);
|
||||
const slice = str.slice();
|
||||
return from(slice);
|
||||
var sliced = value.toSlice(global, bun.default_allocator);
|
||||
defer sliced.deinit();
|
||||
return from(sliced.slice());
|
||||
}
|
||||
|
||||
/// Caller must verify the value is a string
|
||||
|
||||
Reference in New Issue
Block a user