From 778fe2cde0d76f3632462ebfa8dfda81ae791fe1 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 6 Jun 2022 14:43:04 +0300 Subject: [PATCH] ast: use `[direct_array_access]` for `attrs []Attr` lookup methods --- vlib/v/ast/attr.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/v/ast/attr.v b/vlib/v/ast/attr.v index 0366129f0f..24f72afded 100644 --- a/vlib/v/ast/attr.v +++ b/vlib/v/ast/attr.v @@ -54,6 +54,7 @@ pub fn (attrs []Attr) contains(str string) bool { return attrs.any(it.name == str) } +[direct_array_access] pub fn (attrs []Attr) find_first(aname string) ?Attr { for a in attrs { if a.name == aname { @@ -63,6 +64,7 @@ pub fn (attrs []Attr) find_first(aname string) ?Attr { return none } +[direct_array_access] pub fn (attrs []Attr) find_last(aname string) ?Attr { for idx := attrs.len - 1; idx > -1; idx-- { a := attrs[idx] @@ -73,6 +75,7 @@ pub fn (attrs []Attr) find_last(aname string) ?Attr { return none } +[direct_array_access] pub fn (attrs []Attr) find_comptime_define() ?int { for idx in 0 .. attrs.len { if attrs[idx].kind == .comptime_define {