mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
perf(javascript): skip nested callables during fingerprint traversal (#1871)
This commit is contained in:
@@ -179,6 +179,34 @@ describe("JavaScript semantic analysis: calls 2", () => {
|
||||
).not.toBe(left.functionFingerprints[0]?.components.literalSetSha256);
|
||||
});
|
||||
|
||||
it("keeps nested callable syntax out of its owner's fingerprint", () => {
|
||||
const analyze = (nested: number, owned: number) =>
|
||||
analyzeJavaScriptSemantics(`
|
||||
function outer() {
|
||||
function inner() { return ${nested}; }
|
||||
const object = { method() { return ${nested}; } };
|
||||
class Nested { method() { return ${nested}; } }
|
||||
return ${owned};
|
||||
}
|
||||
`);
|
||||
const first = analyze(1, 2);
|
||||
const changedNested = analyze(3, 2);
|
||||
const changedOwner = analyze(1, 4);
|
||||
const syntax = (ir: typeof first) =>
|
||||
ir.functionFingerprints.map(({ components }) => ({
|
||||
ast: components.normalizedAstSha256,
|
||||
control: components.controlFlowSha256,
|
||||
literals: components.literalSetSha256,
|
||||
}));
|
||||
const original = syntax(first);
|
||||
expect(original).toHaveLength(4);
|
||||
expect(syntax(changedNested)[0]).toEqual(original[0]);
|
||||
for (const index of [1, 2, 3])
|
||||
expect(syntax(changedNested)[index]).not.toEqual(original[index]);
|
||||
expect(syntax(changedOwner)[0]).not.toEqual(original[0]);
|
||||
expect(syntax(changedOwner).slice(1)).toEqual(original.slice(1));
|
||||
});
|
||||
|
||||
it("keeps fingerprint relations ordered and effects scoped to their owner", () => {
|
||||
const ordered = analyzeJavaScriptSemantics(`
|
||||
function first() {}
|
||||
|
||||
Reference in New Issue
Block a user