Skip to content

perf: cache API sandbox profile lookups - #57

Merged
humanbydefinition merged 1 commit into
devfrom
perf/cache-api-sandbox-profiles
Aug 23, 2026
Merged

perf: cache API sandbox profile lookups#57
humanbydefinition merged 1 commit into
devfrom
perf/cache-api-sandbox-profiles

Conversation

@humanbydefinition

Copy link
Copy Markdown
Owner

Summary

  • Cache the values of API_SANDBOX_PROFILES once at module initialization.
  • Reuse the cached array in getApiSandboxProfile and getProfileById.
  • Preserve the existing lookup behavior and return values.

Why

The API Sandpack processing path repeatedly called Object.values(API_SANDBOX_PROFILES), allocating a new array for every profile lookup. The profile set is static, so caching the values avoids unnecessary allocations while keeping the code straightforward.

Scope

This PR contains only the source change described above. It does not add tests or alter generated documentation.

Validation

  • node --check scripts/api-sandpack-examples.mjs
  • node scripts/api-sandpack-examples.mjs --check
  • ./node_modules/.bin/vitepress build
  • git diff --check

The API Sandpack check reported 0 transformed files and 661 live examples across 757 scanned files. The VitePress build completed successfully. The build also reported the existing environment warning that the editor sketch loader could not fetch api.github.com.

Cache the profile values once instead of allocating a new array for each profile lookup during API sandbox processing. Preserve the existing lookup behavior while avoiding repeated Object.values calls.
@humanbydefinition
humanbydefinition merged commit 2c65bdc into dev Aug 23, 2026
2 checks passed
@humanbydefinition
humanbydefinition deleted the perf/cache-api-sandbox-profiles branch August 23, 2026 09:13
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.

1 participant