8000 optimized isValidIdentifierContinuationCodePoint · art-divin/swift-syntax@f5d0a3a · GitHub
[go: up one dir, main page]

Skip to content

Commit f5d0a3a

Browse files
committed
optimized isValidIdentifierContinuationCodePoint
1 parent f8be751 commit f5d0a3a

File tree

1 file changed

+92
-46
lines changed

1 file changed

+92
-46
lines changed

Sources/SwiftParser/Lexer/UnicodeScalarExtensions.swift

Lines changed: 92 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,98 @@ extension Unicode.Scalar {
1919
// N1518: Recommendations for extended identifier characters for C and C++
2020
// Proposed Annex X.1: Ranges of characters allowed
2121
let c = self.value
22-
return c == 0x00A8 || c == 0x00AA || c == 0x00AD || c == 0x00AF
23-
|| (c >= 0x00B2 && c <= 0x00B5) || (c >= 0x00B7 && c <= 0x00BA)
24-
|| (c >= 0x00BC && c <= 0x00BE) || (c >= 0x00C0 && c <= 0x00D6)
25-
|| (c >= 0x00D8 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FF)
26-
27-
|| (c >= 0x0100 && c <= 0x167F)
28-
|| (c >= 0x1681 && c <= 0x180D)
29-
|| (c >= 0x180F && c <= 0x1FFF)
30-
31-
|| (c >= 0x200B && c <= 0x200D)
32-
|| (c >= 0x202A && c <= 0x202E)
33-
|| (c >= 0x203F && c <= 0x2040)
34-
|| c == 0x2054
35-
|| (c >= 0x2060 && c <= 0x206F)
36-
37-
|| (c >= 0x2070 && c <= 0x218F)
38-
|| (c >= 0x2460 && c <= 0x24FF)
39-
|| (c >= 0x2776 && c <= 0x2793)
40-
|| (c >= 0x2C00 && c <= 0x2DFF)
41-
|| (c >= 0x2E80 && c <= 0x2FFF)
42-
43-
|| (c >= 0x3004 && c <= 0x3007)
44-
|| (c >= 0x3021 && c <= 0x302F)
45-
|| (c >= 0x3031 && c <= 0x303F)
46-
47-
|| (c >= 0x3040 && c <= 0xD7FF)
48-
49-
|| (c >= 0xF900 && c <= 0xFD3D)
50-
|| (c >= 0xFD40 && c <= 0xFDCF)
51-
|| (c >= 0xFDF0 && c <= 0xFE44)
52-
|| (c >= 0xFE47 && c <= 0xFFF8)
53-
54-
|| (c >= 0x10000 && c <= 0x1FFFD)
55-
|| (c >= 0x20000 && c <= 0x2FFFD)
56-
|| (c >= 0x30000 && c <= 0x3FFFD)
57-
|| (c >= 0x40000 && c <= 0x4FFFD)
58-
|| (c >= 0x50000 && c <= 0x5FFFD)
59-
|| (c >= 0x60000 && c <= 0x6FFFD)
60-
|| (c >= 0x70000 && c <= 0x7FFFD)
61-
|| (c >= 0x80000 && c <= 0x8FFFD)
62-
|| (c >= 0x90000 && c <= 0x9FFFD)
63-
|| (c >= 0xA0000 && c <= 0xAFFFD)
64-
|| (c >= 0xB0000 && c <= 0xBFFFD)
65-
|| (c >= 0xC0000 && c <= 0xCFFFD)
66-
|| (c >= 0xD0000 && c <= 0xDFFFD)
67-
|| (c >= 0xE0000 && c <= 0xEFFFD)
22+
23+
let first: Bool = Bool(c == 0x00A8)
24+
let second: Bool = Bool(c == 0x00AA)
25+
let third: Bool = Bool(c == 0x00AD)
26+
let fourth: Bool = Bool(c == 0x00AF)
27+
let fifth: Bool = Bool(Bool(c >= 0x00B2) && Bool(c <= 0x00B5))
28+
let sixth: Bool = Bool(Bool(c >= 0x00B7) && Bool(c <= 0x00BA))
29+
let seventh: Bool = Bool(Bool(c >=< 8000 /span> 0x00BC) && Bool(c <= 0x00BE))
30+
let eighth: Bool = Bool(Bool(c >= 0x00C0) && Bool(c <= 0x00D6))
31+
let nineth: Bool = Bool(Bool(c >= 0x00D8) && Bool(c <= 0x00F6))
32+
let tenth: Bool = Bool(Bool(c >= 0x00F8) && Bool(c <= 0x00FF))
33+
let eleventh: Bool = Bool(Bool(c >= 0x0100) && Bool(c <= 0x167F))
34+
let twelfth: Bool = Bool(Bool(c >= 0x1681) && Bool(c <= 0x180D))
35+
let thirteenth: Bool = Bool(Bool(c >= 0x180F) && Bool(c <= 0x1FFF))
36+
let fourteenth: Bool = Bool(Bool(c >= 0x200B) && Bool(c <= 0x200D))
37+
let fifteenth: Bool = Bool(Bool(c >= 0x202A) && Bool(c <= 0x202E))
38+
let sixteenth: Bool = Bool(Bool(c >= 0x203F) && Bool(c <= 0x2040))
39+
let seventeenth: Bool = Bool(c == 0x2054)
40+
let eighteenth: Bool = Bool(Bool(c >= 0x2060) && Bool(c <= 0x206F))
41+
let nineteenth: Bool = Bool(Bool(c >= 0x2070) && Bool(c <= 0x218F))
42+
let twentieth: Bool = Bool(Bool(c >= 0x2460) && Bool(c <= 0x24FF))
43+
let twentyfirst: Bool = Bool(Bool(c >= 0x2776) && Bool(c <= 0x2793))
44+
let twentysecond: Bool = Bool(Bool(c >= 0x2C00) && Bool(c <= 0x2DFF))
45+
let twentythird: Bool = Bool(Bool(c >= 0x2E80) && Bool(c <= 0x2FFF))
46+
let twentyfourth: Bool = Bool(Bool(c >= 0x3004) && Bool(c <= 0x3007))
47+
let twentyfifth: Bool = Bool(Bool(c >= 0x3021) && Bool(c <= 0x302F))
48+
let twentysixth: Bool = Bool(Bool(c >= 0x3031) && Bool(c <= 0x303F))
49+
let twentyseventh: Bool = Bool(Bool(c >= 0x3040) && Bool(c <= 0xD7FF))
50+
let twentyeighth: Bool = Bool(Bool(c >= 0xF900) && Bool(c <= 0xFD3D))
51+
let twentyninth: Bool = Bool(Bool(c >= 0xFD40) && Bool(c <= 0xFDCF))
52+
let thirtieth: Bool = Bool(Bool(c >= 0xFDF0) && Bool(c <= 0xFE44))
53+
let thirtyfirst: Bool = Bool(Bool(c >= 0xFE47) && Bool(c <= 0xFFF8))
54+
let thirtysecond: Bool = Bool(Bool(c >= 0x10000) && Bool(c <= 0x1FFFD))
55+
let thirtythird: Bool = Bool(Bool(c >= 0x20000) && Bool(c <= 0x2FFFD))
56+
let thirtyfourth: Bool = Bool(Bool(c >= 0x30000) && Bool(c <= 0x3FFFD))
57+
let thirtyfifth: Bool = Bool(Bool(c >= 0x40000) && Bool(c <= 0x4FFFD))
58+
let thirtysixth: Bool = Bool(Bool(c >= 0x50000) && Bool(c <= 0x5FFFD))
59+
let thirtyseventh: Bool = Bool(Bool(c >= 0x60000) && Bool(c <= 0x6FFFD))
60+
let thirtyeighth: Bool = Bool(Bool(c >= 0x70000) && Bool(c <= 0x7FFFD))
61+
let thirtyninth: Bool = Bool(Bool(c >= 0x80000) && Bool(c <= 0x8FFFD))
62+
let fortieth: Bool = Bool(Bool(c >= 0x90000) && Bool(c <= 0x9FFFD))
63+
let fortyfirst: Bool = Bool(Bool(c >= 0xA0000) && Bool(c <= 0xAFFFD))
64+
let fortysecond: Bool = Bool(Bool(c >= 0xB0000) && Bool(c <= 0xBFFFD))
65+
let fortythird: Bool = Bool(Bool(c >= 0xC0000) && Bool(c <= 0xCFFFD))
66+
let fortyfourth: Bool = Bool(Bool(c >= 0xD0000) && Bool(c <= 0xDFFFD))
67+
let fortyfifth: Bool = Bool(Bool(c >= 0xE0000) && Bool(c <= 0xEFFFD))
68+
return first
69+
|| second
70+
|| third
71+
|| fourth
72+
|| fifth
73+
|| sixth
74+
|| seventh
75+
|| eighth
76+
|| nineth
77+
|| tenth
78+
|| eleventh
79+
|| twelfth
80+
|| thirteenth
81+
|| fourteenth
82+
|| fifteenth
83+
|| sixteenth
84+
|| seventeenth
85+
|| eighteenth
86+
|| nineteenth
87+
|| twentieth
88+
|| twentyfirst
89+
|| twentysecond
90+
|| twentythird
91+
|| twentyfourth
92+
|| twentyfifth
93+
|| twentysixth
94+
|| twentyseventh
95+
|| twentyeighth
96+
|| twentyninth
97+
|| thirtieth
98+
|| thirtyfirst
99+
|| thirtysecond
100+
|| thirtythird
101+
|| thirtyfourth
102+
|| thirtyfifth
103+
|| thirtysixth
104+
|| thirtyseventh
105+
|| thirtyeighth
106+
|| thirtyninth
107+
|| fortieth
108+
|| fortyfirst
109+
|| fortysecond
110+
|| fortythird
111+
|| fortyfourth
112+
|| fortyfifth
113+
68114
}
69115

70116
var isValidIdentifierStartCodePoint: Bool {

0 commit comments

Comments
 (0)
0