From 50277e32e94164a590361ae4617d57f2627700d2 Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Sun, 22 Dec 2024 13:30:56 +0100 Subject: [PATCH] stop trying to be smarter than you are --- quickjs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quickjs.c b/quickjs.c index 957d21f8..d519c518 100644 --- a/quickjs.c +++ b/quickjs.c @@ -54768,9 +54768,10 @@ JSValue JS_NewUint8ArrayCopy(JSContext *ctx, const uint8_t *buf, size_t len) int JS_GetTypedArrayType(JSValue obj) { JSClassID class_id = JS_GetClassID(obj); - int mask = -((class_id >= JS_CLASS_UINT8C_ARRAY) & (class_id <= JS_CLASS_FLOAT64_ARRAY)); - int offset = (class_id - JS_CLASS_UINT8C_ARRAY) & mask; - return offset | (~mask & -1); + if (class_id >= JS_CLASS_UINT8C_ARRAY && class_id <= JS_CLASS_FLOAT64_ARRAY) + return class_id - JS_CLASS_UINT8C_ARRAY; + else + return -1; } /* Atomics */