Skip to content

Commit 3c5f8ab

Browse files
authored
Use internal functions for creating primitives (#1148)
1 parent c0fd00c commit 3c5f8ab

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

quickjs.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,6 @@ static JSValue js_int64(int64_t v)
13791379
return js_float64(v);
13801380
}
13811381

1382-
#define JS_NewInt64(ctx, val) js_int64(val)
1383-
13841382
static JSValue js_number(double d)
13851383
{
13861384
if (double_is_int32(d))
@@ -13817,7 +13815,7 @@ static no_inline __exception int js_unary_arith_slow(JSContext *ctx,
1381713815
default:
1381813816
abort();
1381913817
}
13820-
sp[-1] = JS_NewInt64(ctx, v64);
13818+
sp[-1] = js_int64(v64);
1382113819
}
1382213820
break;
1382313821
case JS_TAG_SHORT_BIG_INT:
@@ -13953,7 +13951,7 @@ static no_inline int js_not_slow(JSContext *ctx, JSValue *sp)
1395313951
int32_t v1;
1395413952
if (unlikely(JS_ToInt32Free(ctx, &v1, op1)))
1395513953
goto exception;
13956-
sp[-1] = JS_NewInt32(ctx, ~v1);
13954+
sp[-1] = js_int32(~v1);
1395713955
}
1395813956
return 0;
1395913957
exception:
@@ -14226,7 +14224,7 @@ static no_inline __exception int js_add_slow(JSContext *ctx, JSValue *sp)
1422614224
v1 = JS_VALUE_GET_INT(op1);
1422714225
v2 = JS_VALUE_GET_INT(op2);
1422814226
v = (int64_t)v1 + (int64_t)v2;
14229-
sp[-2] = JS_NewInt64(ctx, v);
14227+
sp[-2] = js_int64(v);
1423014228
} else if ((tag1 == JS_TAG_BIG_INT || tag1 == JS_TAG_SHORT_BIG_INT) &&
1423114229
(tag2 == JS_TAG_BIG_INT || tag2 == JS_TAG_SHORT_BIG_INT)) {
1423214230
JSBigInt *p1, *p2, *r;
@@ -15021,7 +15019,7 @@ static __exception int js_operator_private_in(JSContext *ctx, JSValue *sp)
1502115019
}
1502215020
JS_FreeValue(ctx, op1);
1502315021
JS_FreeValue(ctx, op2);
15024-
sp[-2] = JS_NewBool(ctx, ret);
15022+
sp[-2] = js_bool(ret);
1502515023
return 0;
1502615024
}
1502715025

@@ -42628,7 +42626,7 @@ static JSValue js_number_constructor(JSContext *ctx, JSValueConst new_target,
4262842626
return val;
4262942627
switch(JS_VALUE_GET_TAG(val)) {
4263042628
case JS_TAG_SHORT_BIG_INT:
42631-
val = JS_NewInt64(ctx, JS_VALUE_GET_SHORT_BIG_INT(val));
42629+
val = js_int64(JS_VALUE_GET_SHORT_BIG_INT(val));
4263242630
if (JS_IsException(val))
4263342631
return val;
4263442632
break;
@@ -42638,7 +42636,7 @@ static JSValue js_number_constructor(JSContext *ctx, JSValueConst new_target,
4263842636
double d;
4263942637
d = js_bigint_to_float64(ctx, p);
4264042638
JS_FreeValue(ctx, val);
42641-
val = JS_NewFloat64(ctx, d);
42639+
val = js_float64(d);
4264242640
}
4264342641
break;
4264442642
default:
@@ -52859,7 +52857,7 @@ static JSValue js_Date_parse(JSContext *ctx, JSValueConst this_val,
5285952857
for(i = 0; i < 7; i++)
5286052858
fields1[i] = fields[i];
5286152859
d = set_date_fields(fields1, is_local) - fields[8] * 60000;
52862-
rv = JS_NewFloat64(ctx, d);
52860+
rv = js_float64(d);
5286352861
}
5286452862
}
5286552863
JS_FreeValue(ctx, s);
@@ -57727,7 +57725,7 @@ static JSValue js_callsite_isnative(JSContext *ctx, JSValueConst this_val, int a
5772757725
JSCallSiteData *csd = JS_GetOpaque2(ctx, this_val, JS_CLASS_CALL_SITE);
5772857726
if (!csd)
5772957727
return JS_EXCEPTION;
57730-
return JS_NewBool(ctx, csd->native);
57728+
return js_bool(csd->native);
5773157729
}
5773257730

5773357731
static JSValue js_callsite_getnumber(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic)
@@ -57736,7 +57734,7 @@ static JSValue js_callsite_getnumber(JSContext *ctx, JSValueConst this_val, int
5773657734
if (!csd)
5773757735
return JS_EXCEPTION;
5773857736
int *field = (void *)((char *)csd + magic);
57739-
return JS_NewInt32(ctx, *field);
57737+
return js_int32(*field);
5774057738
}
5774157739

5774257740
static const JSCFunctionListEntry js_callsite_proto_funcs[] = {

0 commit comments

Comments
 (0)