Skip to content

perf(core): trim what contrastRatio pulls in - #227

Merged
pbroom merged 1 commit into
mainfrom
perf/core-contrast-imports
Oct 10, 2026
Merged

pbroom merged 1 commit into
mainfrom
perf/core-contrast-imports

Conversation

@pbroom

@pbroom pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

oklab.ts destructured all four OKLab matrices into row constants at
module scope. Bundlers keep top-level destructuring even when nothing
reads it, so any bundle that needed only one direction (contrastRatio
needs OKLab -> linear sRGB; parse needs only the reverse) carried the
other two matrices too. Read the rows inside each kernel instead; the
arithmetic is unchanged, so results are bit-identical.

Gzip, size-limit (on top of #225 in parentheses):
contrastRatio alone: 1310 -> 1096 B (1466 -> 1243 B)
parse alone: 4565 -> 4346 B
parse + toHex + contrastRatio: 5233 -> 5225 B (5358 -> 5354 B)
everyday toolkit: 5281 -> 5275 B (5412 -> 5405 B)
packColors + unpackColors: 2317 -> 2277 B

Part of the color-kit assessment stack (#204 → #227). Build, test, lint, typecheck, format, size and check:artifacts pass.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

This was referenced Oct 6, 2026

pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Low risk] Moves matrix destructuring inside functions for bundle size.

This PR appears safe to merge; no actionable issues were found.

What we checked:

  • Color values stay unchanged: The matrices contain fixed numbers and are not changed by repository code. Both functions keep the same calculations and still read every input before writing the output.

Summary

This PR moves matrix reads inside the two OKLab conversion functions so bundles using only one direction can drop the other direction’s matrices.

  • The arithmetic, exports, and input/output behavior stay unchanged.
  • No actionable issues were found. Tests and size measurements were not run during this review.

Reviews (1) · Last reviewed commit: "perf(core): trim what contrastRatio pull..."

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
color-kit Ready Ready Preview Oct 10, 2026 7:53pm UTC

@pbroom
pbroom force-pushed the perf/core-contrast-imports branch from 3b66661 to aa15141 Compare October 8, 2026 02:44
@pbroom
pbroom force-pushed the perf/core-size-budget branch from 9c62afa to a44bd65 Compare October 8, 2026 02:44

pbroom commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Oct 10, 6:47 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 10, 7:44 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 7:44 PM UTC: @pbroom merged this pull request with Graphite.

@pbroom
pbroom changed the base branch from perf/core-size-budget to graphite-base/227 October 10, 2026 19:41
pbroom added a commit that referenced this pull request Oct 10, 2026
Store the 141 distinct CSS Color 4 keywords as one alphabetical,
prefix-coded string (a digit for the letters shared with the previous
name, then the rest) plus one string of fixed-width rrggbb values,
decoded into a Map on first lookup. grey spellings still fold onto gray
and transparent is added separately.

parse + toHex + contrastRatio: 5336 B -> 5233 B gzip (-103 B)
everyday toolkit:              5380 B -> 5281 B gzip (-99 B)

Add a test that the packed table decodes to exactly the CSS Color 4
keyword list (checked against colorjs.io).



Part of the color-kit assessment stack (#204 → #227). Build, test, lint, typecheck, format, size and check:artifacts pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@pbroom
pbroom changed the base branch from graphite-base/227 to main October 10, 2026 19:42
oklab.ts destructured all four OKLab matrices into row constants at
module scope. Bundlers keep top-level destructuring even when nothing
reads it, so any bundle that needed only one direction (contrastRatio
needs OKLab -> linear sRGB; parse needs only the reverse) carried the
other two matrices too. Read the rows inside each kernel instead; the
arithmetic is unchanged, so results are bit-identical.

Gzip, size-limit (on top of #225 in parentheses):
  contrastRatio alone:            1310 -> 1096 B (1466 -> 1243 B)
  parse alone:                    4565 -> 4346 B
  parse + toHex + contrastRatio:  5233 -> 5225 B (5358 -> 5354 B)
  everyday toolkit:               5281 -> 5275 B (5412 -> 5405 B)
  packColors + unpackColors:      2317 -> 2277 B

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the perf/core-contrast-imports branch from aa15141 to a7f2bea Compare October 10, 2026 19:43
@pbroom
pbroom merged commit 58e1a8c into main Oct 10, 2026
6 of 7 checks passed
@pbroom
pbroom deleted the perf/core-contrast-imports branch October 10, 2026 19:44

This branch was successfully deployed

1 active deployment
Preview — a7f2bea1 Deployed Oct 10, 2026 by vercel[bot]
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