Skip to content

Commit b1f761c

Browse files
committed
WIP (reduce number of with_parent calls, move towards possibility of combining tag and tag_proxy)
1 parent d2487f8 commit b1f761c

File tree

1 file changed

+18
-19
lines changed
  • packages/svelte/src/internal/client

1 file changed

+18
-19
lines changed

packages/svelte/src/internal/client/proxy.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,20 @@ export function proxy(value) {
9797
e.state_descriptors_fixed();
9898
}
9999

100-
var s = sources.get(prop);
101-
102-
if (s === undefined) {
103-
s = with_parent(() => source(descriptor.value, stack));
104-
sources.set(prop, s);
100+
with_parent(() => {
101+
var s = sources.get(prop);
105102

106-
if (DEV && typeof prop === 'string') {
107-
tag(s, get_label(path, prop));
108-
}
109-
} else {
110-
var p = with_parent(() => proxy(descriptor.value));
111-
set(s, p);
103+
if (s === undefined) {
104+
s = source(descriptor.value, stack);
105+
sources.set(prop, s);
112106

113-
if (DEV) {
114-
tag_proxy(p, get_label(path, prop));
107+
if (DEV && typeof prop === 'string') {
108+
tag(s, get_label(path, prop));
109+
}
110+
} else {
111+
set(s, descriptor.value, true);
115112
}
116-
}
113+
});
117114

118115
return true;
119116
},
@@ -278,22 +275,24 @@ export function proxy(value) {
278275
// object property before writing to that property.
279276
if (s === undefined) {
280277
if (!has || get_descriptor(target, prop)?.writable) {
281-
s = with_parent(() => source(undefined, stack));
282-
var p = with_parent(() => proxy(value));
278+
s = with_parent(() => {
279+
var s = source(undefined, stack);
280+
set(s, proxy(value));
281+
return s;
282+
});
283283

284284
if (DEV) {
285285
var label = get_label(path, prop);
286286
tag(s, label);
287-
tag_proxy(p, label);
287+
tag_proxy(s.v, label);
288288
}
289289

290-
set(s, p);
291290
sources.set(prop, s);
292291
}
293292
} else {
294293
has = s.v !== UNINITIALIZED;
295294

296-
p = with_parent(() => proxy(value));
295+
var p = with_parent(() => proxy(value));
297296

298297
if (DEV) {
299298
tag_proxy(p, get_label(path, prop));

0 commit comments

Comments
 (0)