tailwindcss/packages
Robin Malfait af3345189a
Improve walk(…) performance (#15529)
This PR is a tiny improvement to the `walk(…)` implementations, not a
super big
deal but thought about something and was pleasently surprised that it
did have
an impact.

The idea is twofold:

1. Reduce array allocations while walking to build a `path` to the
current node. This re-uses the existing `path` array and pushes the
current node before the recursive call and pops it afterwards. This way
we don't need to allocate a new array for each recursive call. Testing
this on Tailwind UI means ~14k fewer allocations.
2. Instead of always calling `.splice(…)`, we can directly update a
single value in the array if we are replacing a node with another node.
   
Testing on the Tailwind UI codebase, this results in:

![image](https://github.com/user-attachments/assets/5a1c2102-1493-410f-b527-847fb4a75b31)

---------

Co-authored-by: Philipp Spiess <hello@philippspiess.com>
2025-01-06 14:27:55 +00:00
..
@tailwindcss-cli Prepare v4.0.0-beta.8 release (#15418) 2024-12-17 13:31:28 +01:00
@tailwindcss-node Update jiti 2.4.0 → 2.4.2 (patch) (#15491) 2025-01-06 11:42:53 +01:00
@tailwindcss-postcss Move --container-prose to --max-width-prose (#15439) 2024-12-18 20:15:37 -05:00
@tailwindcss-standalone Update bun 1.1.40 → 1.1.42 (patch) (#15551) 2025-01-06 12:45:16 +01:00
@tailwindcss-upgrade Prepare v4.0.0-beta.8 release (#15418) 2024-12-17 13:31:28 +01:00
@tailwindcss-vite Prepare v4.0.0-beta.8 release (#15418) 2024-12-17 13:31:28 +01:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Improve walk(…) performance (#15529) 2025-01-06 14:27:55 +00:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00