From 7b59d9d97c4d4543d8fe2a2222781d7b89539fc2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 28 Nov 2022 23:47:46 -0800 Subject: Make .toInt64 faster --- src/bun.js/bindings/bindings.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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}); } -- cgit v1.2.3