Skip to content

perf: precompute SPDX ID Set for O(1) license validation lookups#113

Merged
ethanholz merged 2 commits intofix/spdxfrom
copilot/sub-pr-111-again
Mar 7, 2026
Merged

perf: precompute SPDX ID Set for O(1) license validation lookups#113
ethanholz merged 2 commits intofix/spdxfrom
copilot/sub-pr-111-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

ALL_SPDX_IDS.includes(license) in the superRefine callback was doing a linear scan over thousands of SPDX entries on every validation call — which fires on each keystroke via isValid()/safeParse.

Changes

  • src/schemas.ts: Precompute SPDX_ID_SET = new Set(ALL_SPDX_IDS) once at module load; replace Array.includes() with Set.has() in the refinement loop.
// Before
!ALL_SPDX_IDS.includes(license)

// After
const SPDX_ID_SET = new Set(ALL_SPDX_IDS);
// ...
!SPDX_ID_SET.has(license)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ethanholz <6245717+ethanholz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SPDX license handling based on review feedback perf: precompute SPDX ID Set for O(1) license validation lookups Mar 7, 2026
@ethanholz ethanholz marked this pull request as ready for review March 7, 2026 06:15
@ethanholz ethanholz merged commit 2d941a1 into fix/spdx Mar 7, 2026
@ethanholz ethanholz deleted the copilot/sub-pr-111-again branch March 7, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants