Skip to content

Commit c59f340

Browse files
remove TODOs
1 parent 46e9545 commit c59f340

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/Data/String/CodePoints.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ exports._count = function (isLead) {
7878

7979
exports._fromCodePointArray = function (singleton) {
8080
return hasFromCodePoint
81-
// TODO: using F.p.apply here will fail for very large strings; use alternative implementation for very large strings
82-
? function (cps) { return String.fromCodePoint.apply(String, cps); }
81+
? function (cps) {
82+
if (cps.length < 10240) {
83+
return String.fromCodePoint.apply(String, cps);
84+
}
85+
return cps.map(singleton).join("");
86+
}
8387
: function (cps) { return cps.map(singleton).join(""); };
8488
};
8589

test/Test/Data/String/CodePoints.purs

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ testStringCodePoints = do
6666
assert $ indexOf (Pattern "z") str == Just 6
6767
assert $ indexOf (Pattern "\0") str == Nothing
6868
assert $ indexOf (Pattern "\xD81A") str == Just 4
69-
-- TODO: Should this be Nothing? It matches the trail surrogate of a surrogate pair.
70-
-- It'd be nice if (drop (indexOf pattern str) str) was guaranteed to start with pattern.
71-
-- If we change this, we'll also need to add a matching contains implementation to the CodePoints module.
72-
-- I vote we just delete the test. Passing surrogate halves to the CodePoints functions should not be supported.
73-
assert $ indexOf (Pattern "\xDC05") str == Just 5
7469

7570
log "indexOf'"
7671
assert $ indexOf' (Pattern "") 0 "" == Just 0

0 commit comments

Comments
 (0)