Skip to content

Commit fae1d30

Browse files
committed
feat: small optimization of regex
1 parent 273a1e6 commit fae1d30

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/kotlin/app/extractors/ExtractorInterface.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ interface ExtractorInterface {
105105

106106
fun tokenize(line: String): List<String> {
107107
// TODO(lyaronskaya): Multiline comment regex.
108+
109+
// TODO(anatoly): Optimize this regex, better to get rid of it.
108110
val newLine = stringRegex.replace(line, "")
109-
val tokens = splitRegex.split(newLine).filter {
110-
it.isNotBlank() && !it.contains('"') && !it.contains('\'') &&
111+
112+
val tokens = newLine.split(' ', '[', ',', ';', '*', '\n', ')', '(',
113+
'[', ']', '}', '{', '+', '-', '=', '&', '$', '!', '.', '>', '<',
114+
'#', '@', ':', '?', ']')
115+
.filter {
116+
it.isNotBlank() && !it.contains('"') && !it.contains('\'') &&
111117
it != "-" && it != "@"
112-
}
118+
}
119+
113120
return tokens
114121
}
115122

0 commit comments

Comments
 (0)