mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
refactor SPECIALS_TABLE
This commit is contained in:
@@ -558,13 +558,23 @@ push_captures :: proc(
|
|||||||
|
|
||||||
// SPECIALS := "^$*+?.([%-"
|
// SPECIALS := "^$*+?.([%-"
|
||||||
// all special characters inside a small ascii array
|
// all special characters inside a small ascii array
|
||||||
SPECIALS_TABLE := [256]u8 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
SPECIALS_TABLE := [256]bool {
|
||||||
|
'^' = true,
|
||||||
|
'$' = true,
|
||||||
|
'*' = true,
|
||||||
|
'+' = true,
|
||||||
|
'?' = true,
|
||||||
|
'.' = true,
|
||||||
|
'(' = true,
|
||||||
|
'[' = true,
|
||||||
|
'%' = true,
|
||||||
|
'-' = true,
|
||||||
|
}
|
||||||
|
|
||||||
// helper call to quick search for special characters
|
// helper call to quick search for special characters
|
||||||
index_special :: proc(text: string) -> int {
|
index_special :: proc(text: string) -> int {
|
||||||
// TODO is this utf8 safe?
|
|
||||||
for i in 0..<len(text) {
|
for i in 0..<len(text) {
|
||||||
if SPECIALS_TABLE[text[i]] == 1 {
|
if SPECIALS_TABLE[text[i]] {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user