diff options
author | 2022-11-28 23:47:46 -0800 | |
---|---|---|
committer | 2022-11-28 23:48:04 -0800 | |
commit | 7b59d9d97c4d4543d8fe2a2222781d7b89539fc2 (patch) | |
tree | 6c9f02ffa5fe242b606fb85c6018b17c3074a857 | |
parent | d28247573cd8e019b835452bbec191dadc38d86d (diff) | |
download | bun-7b59d9d97c4d4543d8fe2a2222781d7b89539fc2.tar.gz bun-7b59d9d97c4d4543d8fe2a2222781d7b89539fc2.tar.zst bun-7b59d9d97c4d4543d8fe2a2222781d7b89539fc2.zip |
Make .toInt64 faster
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index ab8286b06..3fada34c4 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -3135,6 +3135,14 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn toInt64(this: JSValue) i64 { + if (this.isInt32()) { + return this.asInt32(); + } + + if (this.isNumber()) { + return @floatToInt(i64, this.asDouble()); + } + return cppFn("toInt64", .{this}); } |