@@ -3,7 +3,7 @@ import std/sets
33
44import pkg/ unicodedb/ properties
55import pkg/ unicodedb/ types
6- import pkg/ unicodeplus except isUpper, isLower
6+ import pkg/ unicodeplus
77
88import nodetype
99import common
@@ -23,12 +23,9 @@ func isWordAscii(r: Rune): bool {.inline.} =
2323 else :
2424 false
2525
26- template isWordBoundaryImpl (r, nxt, alnumProc): bool =
27- let
28- isWord = r != invalidRune and alnumProc (r)
29- isNxtWord = nxt != invalidRune and alnumProc (nxt)
30- ((isWord and not isNxtWord) or
31- (not isWord and isNxtWord))
26+ template isWordBoundaryImpl (r, nxt, isWordProc): bool =
27+ (r.int > - 1 and isWordProc (r)) xor
28+ (nxt.int > - 1 and isWordProc (nxt))
3229
3330func isWordBoundary (r: Rune , nxt: Rune ): bool {.inline .} =
3431 # # check if current match
@@ -108,17 +105,11 @@ func isAnyAscii(r: Rune): bool {.inline.} =
108105 (r.int <= int8 .high and
109106 r != lineBreakRune)
110107
111- # todo : can not use unicodeplus due to
112- # https://github.com/nim-lang/Nim/issues/7059
113- func swapCase * (r: Rune ): Rune =
114- # Note a character can be
115- # non-lower and non-upper
116- if r.isUpper ():
117- result = r.toLower ()
118- elif r.isLower ():
119- result = r.toUpper ()
120- else :
121- result = r
108+ func swapCase (r: Rune ): Rune =
109+ result = r.toLower ()
110+ if result != r:
111+ return
112+ result = r.toUpper ()
122113
123114func match * (n: Node , r: Rune ): bool =
124115 # # match for ``Node`` of matchable kind.
0 commit comments