Skip to content

Commit 60f2757

Browse files
committed
Relocate extension fns **&** add whitespace fn
1 parent 541b594 commit 60f2757

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/kotlin/lexer/StringJSONLexer.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,21 @@ class StringJSONLexer(private val content: CharSequence) : JSONLexer {
167167
}
168168

169169
private fun skipWhitespace() {
170-
while (!(position >= content.length || !Character.isWhitespace(content.getChar(position)))) {
170+
while (!(position >= content.length || !content.getChar(position).isWhitespace())) {
171171
position++
172172
}
173173
}
174-
}
175174

176-
private fun CharSequence.getChar(index: Int): Char {
177-
if (index >= this.length) {
178-
return 0.toChar()
175+
private fun CharSequence.getChar(index: Int): Char {
176+
if (index >= this.length) {
177+
return 0.toChar()
178+
}
179+
180+
return this[index]
179181
}
180182

181-
return this[index]
182-
}
183+
private fun Char.isWhitespace(): Boolean {
184+
return this == ' ' || this == '\r' || this == '\n' || this == '\t'
185+
}
186+
}
187+

0 commit comments

Comments
 (0)