Remove helpers.deepFreeze and call Object.freeze only on things that need it for ~11% time reduction measured via profile-fixture.mjs on Apple Silicon M1.

This commit is contained in:
David Anson 2022-06-09 23:56:44 -07:00
parent b6471fba31
commit 936c876810
5 changed files with 110 additions and 97 deletions

View file

@ -953,40 +953,6 @@ test("applyFixes", (t) => {
}
});
test("deepFreeze", (t) => {
t.plan(6);
const obj = {
"prop": true,
"func": () => true,
"sub": {
"prop": [ 1 ],
"sub": {
"prop": "one"
}
}
};
t.is(helpers.deepFreeze(obj), obj, "Did not return object.");
for (const scenario of [
() => {
obj.prop = false;
},
() => {
obj.func = () => false;
},
() => {
obj.sub.prop = [];
},
() => {
obj.sub.prop[0] = 0;
},
() => {
obj.sub.sub.prop = "zero";
}
]) {
t.throws(scenario, null, "Assigned to frozen object.");
}
});
test("forEachLink", (t) => {
t.plan(291);
const testCases = [