Skip to content

Commit e3aea17

Browse files
authored
chore: tweak tripleBar parsing. (#435)
Motivation: For simple cases, optimize CharsWhileIn` to `CharsWhile`
1 parent ae33f00 commit e3aea17

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sjsonnet/src/sjsonnet/Parser.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ object Parser {
6666
def idStartChar(c: Char): Boolean = c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
6767

6868
private val emptyLazyArray = new Array[Lazy](0)
69+
private val isSpaceOrTab: Char => Boolean = c => c == ' ' || c == '\t'
6970
}
7071

7172
class Parser(
@@ -148,10 +149,10 @@ class Parser(
148149
lines
149150
}
150151

151-
def tripleBarJunk[$: P]: P[Unit] = CharsWhileIn(" \t", 0)
152+
def tripleBarJunk[$: P]: P[Unit] = CharsWhile(isSpaceOrTab, 0)
152153

153154
def tripleBarIndent[$: P]: P[String] = P(
154-
CharsWhileIn(" \t", 1)
155+
CharsWhile(isSpaceOrTab, 1)
155156
.opaque("|||-block line must either be an empty line or start with at least one whitespace")
156157
.!
157158
)

0 commit comments

Comments
 (0)