MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

with() direct own-shape fast path for ordinary objects

+27 -8
+27 -8
src/silver/ops/coercion.h
··· 239 239 } 240 240 } 241 241 242 + static inline bool sv_try_get_with_bound_value( 243 + ant_t *js, 244 + ant_value_t with_obj, 245 + const sv_atom_t *a, 246 + ant_value_t *out 247 + ) { 248 + ant_object_t *ptr = is_object_type(with_obj) ? js_obj_ptr(js_as_obj(with_obj)) : NULL; 249 + const char *interned = intern_string(a->str, a->len); 250 + 251 + if (ptr && interned) { 252 + bool should_fallback = false; 253 + if (sv_try_get_shape_data_prop(js, ptr, interned, out, &should_fallback)) return true; 254 + if (!should_fallback) return false; 255 + } 256 + 257 + if (lkp(js, with_obj, a->str, a->len) == 0) return false; 258 + *out = sv_getprop_fallback_len(js, with_obj, a->str, (ant_offset_t)a->len); 259 + 260 + return true; 261 + } 262 + 242 263 static inline ant_value_t sv_op_with_get_var( 243 264 sv_vm_t *vm, ant_t *js, 244 265 sv_frame_t *frame, ··· 250 271 sv_atom_t *a = &func->atoms[atom_idx]; 251 272 252 273 if (vtype(frame->with_obj) != T_UNDEF) { 253 - if (lkp(js, frame->with_obj, a->str, a->len) != 0) { 254 - ant_value_t val = sv_getprop_fallback_len( 255 - js, frame->with_obj, a->str, (ant_offset_t)a->len); 256 - if (is_err(val)) return val; 257 - vm->stack[vm->sp++] = val; 258 - return js_mkundef(); 259 - } 260 - } 274 + ant_value_t val = js_mkundef(); 275 + if (sv_try_get_with_bound_value(js, frame->with_obj, a, &val)) { 276 + if (is_err(val)) return val; 277 + vm->stack[vm->sp++] = val; 278 + return js_mkundef(); 279 + }} 261 280 262 281 if (fb_kind == WITH_FB_GLOBAL) { 263 282 ant_value_t val = sv_global_get(js, a->str, a->len);