Skip to content

Commit 6ea0420

Browse files
committed
fixup: use get_func_name
1 parent 2335bb6 commit 6ea0420

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

quickjs.c

+7-15
Original file line numberDiff line numberDiff line change
@@ -8888,22 +8888,14 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop,
88888888
JSObject *vf = JS_VALUE_GET_OBJ(val);
88898889
if (vf->class_id == JS_CLASS_BYTECODE_FUNCTION &&
88908890
vf->u.func.var_refs == NULL) {
8891-
JSValue name_val = JS_GetProperty(ctx, val, JS_ATOM_name);
8892-
8893-
if (JS_IsString(name_val)) {
8894-
const char *name = JS_ToCString(ctx, name_val);
8895-
if (name != NULL) {
8896-
if (strcmp(name, "") == 0) {
8897-
JSValue js_value = JS_AtomToValue(ctx, prop);
8898-
JS_DefinePropertyValue(ctx, val, JS_ATOM_name, js_value, JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE);
8899-
JS_FreeValue(ctx, js_value);
8900-
}
8901-
8902-
JS_FreeCString(ctx, name);
8903-
}
8904-
8891+
const char* name = get_func_name(ctx, val);
8892+
if (strcmp(name, "") == 0) {
8893+
JSValue js_value = JS_AtomToValue(ctx, prop);
8894+
JS_DefinePropertyValue(ctx, val, JS_ATOM_name, js_value, JS_PROP_CONFIGURABLE | JS_PROP_WRITABLE);
8895+
JS_FreeValue(ctx, js_value);
89058896
}
8906-
JS_FreeValue(ctx, name_val);
8897+
8898+
JS_FreeCString(ctx, name);
89078899
}
89088900
}
89098901

0 commit comments

Comments
 (0)