Skip to content

Commit 3e412c1

Browse files
authored
refactor(reactive): reduce code size by assigning to a local variable (#1634)
1 parent fb8e83f commit 3e412c1

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/reactivity/src/reactive.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,11 @@ function createReactiveObject(
141141
return target
142142
}
143143
// target already has corresponding Proxy
144-
if (
145-
hasOwn(target, isReadonly ? ReactiveFlags.READONLY : ReactiveFlags.REACTIVE)
146-
) {
147-
return isReadonly
148-
? target[ReactiveFlags.READONLY]
149-
: target[ReactiveFlags.REACTIVE]
144+
const reactiveFlag = isReadonly
145+
? ReactiveFlags.READONLY
146+
: ReactiveFlags.REACTIVE
147+
if (hasOwn(target, reactiveFlag)) {
148+
return target[reactiveFlag]
150149
}
151150
// only a whitelist of value types can be observed.
152151
if (!canObserve(target)) {
@@ -156,11 +155,7 @@ function createReactiveObject(
156155
target,
157156
collectionTypes.has(target.constructor) ? collectionHandlers : baseHandlers
158157
)
159-
def(
160-
target,
161-
isReadonly ? ReactiveFlags.READONLY : ReactiveFlags.REACTIVE,
162-
observed
163-
)
158+
def(target, reactiveFlag, observed)
164159
return observed
165160
}
166161

0 commit comments

Comments
 (0)