Skip to content

Commit 550a064

Browse files
committed
reduce indirection
1 parent 8197537 commit 550a064

File tree

1 file changed

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

1 file changed

+12
-18
lines changed

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ export function source(v, stack) {
7676
* @param {V} v
7777
*/
7878
export function state(v) {
79-
return push_derived_source(source(v));
79+
var s = source(v);
80+
81+
// TODO maybe we make this dev-only?
82+
if (active_reaction !== null && !untracking && (active_reaction.f & DERIVED) !== 0) {
83+
if (derived_sources === null) {
84+
set_derived_sources([s]);
85+
} else {
86+
derived_sources.push(s);
87+
}
88+
}
89+
90+
return s;
8091
}
8192

8293
/**
@@ -101,23 +112,6 @@ export function mutable_source(initial_value, immutable = false) {
101112
return s;
102113
}
103114

104-
/**
105-
* @template V
106-
* @param {Source<V>} source
107-
*/
108-
/*#__NO_SIDE_EFFECTS__*/
109-
function push_derived_source(source) {
110-
if (active_reaction !== null && !untracking && (active_reaction.f & DERIVED) !== 0) {
111-
if (derived_sources === null) {
112-
set_derived_sources([source]);
113-
} else {
114-
derived_sources.push(source);
115-
}
116-
}
117-
118-
return source;
119-
}
120-
121115
/**
122116
* @template V
123117
* @param {Value<V>} source

0 commit comments

Comments
 (0)