CodePoints.uncons performance optimization?

Open
#154 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
performance

Research direction

Start with Data.String.CodePoints.uncons in src/Data/String/CodePoints.purs and the related helper in src/Data/String/Unsafe.js, then compare the referenced Data/Enum.js implementation. Confirm that the intermediate charAt slice can be avoided by using charCodeAt directly, while preserving uncons behavior.

Written by the indexing model from the issue text.

Description

type: enhancement

It seems to me that these lines in Data.String.CodePoints.uncons

https://github.com/purescript/purescript-strings/blob/157e372a23e4becd594d7e7bff6f372a6f63dd82/src/Data/String/CodePoints.purs#L197-L198

are first slicing the first code unit into a Char string with the JavaScript charAt method

https://github.com/purescript/purescript-strings/blob/157e372a23e4becd594d7e7bff6f372a6f63dd82/src/Data/String/Unsafe.js#L5

and then converting the Char string to a CodePoint by the boundedEnumChar instance fromEnum method which calls the Javascript charCodeAt method.

https://github.com/purescript/purescript-enums/blob/170d959644eb99e0025f4ab2e38f5f132fd85fa4/src/Data/Enum.js#L4

We could skip the intermediate string slice of the charAt method and call charCodeAt directly.

Dominant language
PureScript
Stars
57
Forks
76
PR merge metrics
No merged PRs in 30d

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.

More from purescript/purescript-strings

All issues in purescript/purescript-strings

Similar issues

More Performance issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.