From 7d92d93a550f3be221d7cf1da07c37ea1770e922 Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Sun, 11 Oct 2026 14:06:41 -0700 Subject: [PATCH] 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 Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> --- src/dotnet/ManagedMemberOwnership.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dotnet/ManagedMemberOwnership.test.ts b/src/dotnet/ManagedMemberOwnership.test.ts index c734aa05c..9e570a195 100644 --- a/src/dotnet/ManagedMemberOwnership.test.ts +++ b/src/dotnet/ManagedMemberOwnership.test.ts @@ -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]); });