Open jamesdbrock opened 3 years ago
Is it doing that because it makes it easier on other backends?
Is it doing that because it makes it easier on other backends?
Maybe. That's a good point.
I tried swapping in a “fast” CodePoints.uncons
function in purescript-parsing and couldn't detect any speedup.
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 JavaScriptcharAt
methodhttps://github.com/purescript/purescript-strings/blob/157e372a23e4becd594d7e7bff6f372a6f63dd82/src/Data/String/Unsafe.js#L5
and then converting the
Char
string to aCodePoint
by theboundedEnumChar
instancefromEnum
method which calls the JavascriptcharCodeAt
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 callcharCodeAt
directly.