aboutsummaryrefslogtreecommitdiff
path: root/core/strings
diff options
context:
space:
mode:
authorRicardo Silva <ricardo.silva@talkdesk.com>2021-09-07 18:33:59 +0100
committerRicardo Silva <ricardo.silva@talkdesk.com>2021-09-07 18:38:10 +0100
commitf6d496c81deeff1e4b1cab1cbe41a540d82334ee (patch)
tree9020f8854a218f29477613c31682efe1e7d2bc91 /core/strings
parent1dffd4ea3dc93480019016ce0a8204191f3e8b81 (diff)
Fix strings.index_any on small strings
Diffstat (limited to 'core/strings')
-rw-r--r--core/strings/strings.odin6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/strings/strings.odin b/core/strings/strings.odin
index 6ace03b48..9179a9046 100644
--- a/core/strings/strings.odin
+++ b/core/strings/strings.odin
@@ -479,7 +479,7 @@ last_index :: proc(s, substr: string) -> int {
return -1
}
-
+// index_any returns the index of the first char of `chars` found in `s`. -1 if not found.
index_any :: proc(s, chars: string) -> int {
if chars == "" {
return -1
@@ -504,8 +504,8 @@ index_any :: proc(s, chars: string) -> int {
}
}
- for c, i in chars {
- if index_rune(chars, c) >= 0 {
+ for c in chars {
+ if i := index_rune(s, c); i >= 0 {
return i
}
}