1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: optimize generated array.index(elem)

This commit is contained in:
Delyan Angelov
2021-06-28 17:45:04 +03:00
parent 4af4f2b5a5
commit 63638fd271
2 changed files with 9 additions and 7 deletions

View File

@@ -568,6 +568,7 @@ pub fn (mut a []int) sort() {
// index returns the first index at which a given element can be found in the array
// or -1 if the value is not found.
[direct_array_access]
pub fn (a []string) index(v string) int {
for i in 0 .. a.len {
if a[i] == v {