Skip to content

Commit d2a8ec8

Browse files
committed
squash: move caching higher
1 parent 52d06b7 commit d2a8ec8

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

test/common/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,11 @@ function mustNotCall(msg) {
522522
const _mustNotMutateProxies = new WeakMap();
523523

524524
function mustNotMutate(object) {
525+
const cachedProxy = _mustNotMutateProxies.get(object);
526+
if (cachedProxy) {
527+
return cachedProxy;
528+
}
529+
525530
const _mustNotMutateHandler = {
526531
defineProperty(target, property, descriptor) {
527532
assert.fail(`Expected no side effects, got ${property} defined`);
@@ -548,13 +553,9 @@ function mustNotMutate(object) {
548553
}
549554
};
550555

551-
const cachedProxy = _mustNotMutateProxies.get(object);
552-
if (cachedProxy) {
553-
return cachedProxy;
554-
}
555-
const newProxy = new Proxy(object, _mustNotMutateHandler);
556-
_mustNotMutateProxies.set(object, newProxy);
557-
return newProxy;
556+
const proxy = new Proxy(object, _mustNotMutateHandler);
557+
_mustNotMutateProxies.set(object, proxy);
558+
return proxy;
558559
}
559560

560561
function printSkipMessage(msg) {

0 commit comments

Comments
 (0)