fix(managed): share first-match member list ownership (#1955)
Inventory attribute lookups and the members inspector each interpreted TypeDef member-list ownership. The members lookup binary-searched ordered ranges but fell back to a per-member scan of every type when malformed lists were unordered, which was quadratic (8 s for 100,000 types). Both now use firstMatchListOwners, one near-linear first-match index over one-based list positions. Remove the ordered/fallback split and the production declaringType scan, which remains only as the test oracle. The inventory reserves only its retained index. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
morluto
parent
eb97da3388
commit
7d92d93a55
@@ -81,7 +81,7 @@ describe("managed declaring type ownership", () => {
|
||||
);
|
||||
|
||||
it("indexes large unordered member lists once per layout", () => {
|
||||
const count = 40_000;
|
||||
const count = 100_000;
|
||||
const bytes = buildManagedPeFixture({
|
||||
additionalEmptyTypes: count - 1,
|
||||
methodRowCount: count,
|
||||
@@ -95,13 +95,17 @@ describe("managed declaring type ownership", () => {
|
||||
2 * layout.stringIndexSize +
|
||||
layout.codedIndexSize("TypeDefOrRef") +
|
||||
memberListIndexSize(layout, 4);
|
||||
bytes.writeUInt16LE(2, methodOffset);
|
||||
// The first reversed range forces first-match semantics, with the owner last.
|
||||
// 100,000 MethodDef rows require a four-byte method-list index.
|
||||
bytes.writeUInt32LE(2, methodOffset);
|
||||
const start = performance.now();
|
||||
const lookup = memberDeclaringTypeRowLookup(bytes, layout, 6);
|
||||
expect(
|
||||
Array.from({ length: count }, (_, row) => lookup(row + 1)).every(
|
||||
(owner) => owner === count,
|
||||
),
|
||||
).toBe(true);
|
||||
expect(performance.now() - start).toBeLessThan(2000);
|
||||
expect(memberDeclaringTypeRowLookup(bytes, layout, 6)).toBe(lookup);
|
||||
expect([lookup(0), lookup(count + 1)]).toEqual([0, 0]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user