mathiasbynens / mathiasbynens/punycode.js

Improve V8-specific performance

Open
#49 0 comments 1 reaction 0 assignees View on GitHub

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() calls String#split() twice and is heavy on the map-over-substrings idiom. It would probably be faster to:

  1. Scan for the split character and only split when found; saves allocating an array in the common case.
  2. Iterate rather than map; V8 is not great at lowering/inlining callbacks.
  3. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.