From 63a0395a79505598ae89c756c7394765bd89c1aa Mon Sep 17 00:00:00 2001 From: skytrias Date: Wed, 21 Dec 2022 22:08:03 +0100 Subject: [PATCH] refactor SPECIALS_TABLE --- core/text/match/strlib.odin | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/text/match/strlib.odin b/core/text/match/strlib.odin index d299dc43d..b8c2861fa 100644 --- a/core/text/match/strlib.odin +++ b/core/text/match/strlib.odin @@ -558,13 +558,23 @@ push_captures :: proc( // SPECIALS := "^$*+?.([%-" // 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 index_special :: proc(text: string) -> int { - // TODO is this utf8 safe? for i in 0..