Skip to content

Commit 3b57fd4

Browse files
remove duplication
1 parent 205838c commit 3b57fd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Data/String/CodePoints.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ codePointFromSurrogatePair lead trail | isLead lead && isTrail trail =
6262
codePointFromSurrogatePair _ _ = Nothing
6363

6464
unsurrogate :: Int -> Int -> CodePoint
65-
unsurrogate h l = CodePoint ((h - 0xD800) * 0x400 + (l - 0xDC00) + 0x10000)
65+
unsurrogate lead trail = CodePoint ((lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000)
6666

6767
isLead :: Int -> Boolean
6868
isLead cu = 0xD800 <= cu && cu <= 0xDBFF
@@ -83,7 +83,7 @@ foreign import _unsafeCodePointAt0
8383

8484
unsafeCodePointAt0Fallback :: String -> CodePoint
8585
unsafeCodePointAt0Fallback s | String.length s == 1 = CodePoint (Unsafe.charCodeAt 0 s)
86-
unsafeCodePointAt0Fallback s = CodePoint (((lead - 0xD800) * 0x400) + (trail - 0xDC00) + 0x10000)
86+
unsafeCodePointAt0Fallback s = CodePoint (unsurrogate lead trail)
8787
where
8888
lead = Unsafe.charCodeAt 0 s
8989
trail = Unsafe.charCodeAt 1 s

0 commit comments

Comments
 (0)