mathiasbynens / mathiasbynens/punycode.js
Improve V8-specific performance
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 170
- PR merge metrics
- No merged PRs in 30d
Description
@bnoordhuis posted some excellent ideas here:
For example,
.toASCII()callsString#split()twice and is heavy on the map-over-substrings idiom. It would probably be faster to:
- Scan for the split character and only split when found; saves allocating an array in the common case.
- Iterate rather than map; V8 is not great at lowering/inlining callbacks.
- Try to avoid concatenating strings too much; cons strings eventually have to be flattened.
There is probably more but that is what stood out from a quick look.
Patches welcome.
cc @trevnorris
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the .toASCII() implementation and reviewing its String#split(), map-over-substrings, and string-concatenation paths. The issue proposes avoiding unnecessary splits, iterating instead of mapping, and reducing concatenation; done means implementing the relevant improvements while preserving the converter’s existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100