From 976ccb9224151ca2aa10a35e5ee92f4d85cd2d71 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 3 Apr 2025 13:47:03 +0200 Subject: [PATCH] LibJS: Add fast path for Int32 values in ToBoolean It's not uncommon to branch on the boolean value of integers, so let's do that on the ToBoolean fast path. --- Libraries/LibJS/Runtime/ValueInlines.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libraries/LibJS/Runtime/ValueInlines.h b/Libraries/LibJS/Runtime/ValueInlines.h index a424ab9f885..94d96701596 100644 --- a/Libraries/LibJS/Runtime/ValueInlines.h +++ b/Libraries/LibJS/Runtime/ValueInlines.h @@ -17,6 +17,9 @@ inline bool Value::to_boolean() const if (is_boolean()) return as_bool(); + if (is_int32()) + return as_i32() != 0; + return to_boolean_slow_case(); }