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

ast: speed up the frequently called methods .find_field, .find_method etc

This commit is contained in:
Delyan Angelov 2021-11-07 18:05:20 +02:00
parent 9ec1262734
commit bc98da9111
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -1184,7 +1184,7 @@ pub fn (t &TypeSymbol) embed_name() string {
}
pub fn (t &TypeSymbol) has_method(name string) bool {
for method in t.methods {
for mut method in unsafe { t.methods } {
if method.name == name {
return true
}
@ -1198,7 +1198,7 @@ pub fn (t &TypeSymbol) has_method_with_generic_parent(name string) bool {
}
pub fn (t &TypeSymbol) find_method(name string) ?Fn {
for method in t.methods {
for mut method in unsafe { t.methods } {
if method.name == name {
return method
}
@ -1272,7 +1272,7 @@ pub fn (t &TypeSymbol) find_field(name string) ?StructField {
}
fn (a &Aggregate) find_field(name string) ?StructField {
for field in a.fields {
for mut field in unsafe { a.fields } {
if field.name == name {
return field
}
@ -1281,7 +1281,7 @@ fn (a &Aggregate) find_field(name string) ?StructField {
}
pub fn (i &Interface) find_field(name string) ?StructField {
for field in i.fields {
for mut field in unsafe { i.fields } {
if field.name == name {
return field
}
@ -1290,7 +1290,7 @@ pub fn (i &Interface) find_field(name string) ?StructField {
}
pub fn (i &Interface) find_method(name string) ?Fn {
for method in i.methods {
for mut method in unsafe { i.methods } {
if method.name == name {
return method
}
@ -1299,7 +1299,7 @@ pub fn (i &Interface) find_method(name string) ?Fn {
}
pub fn (i &Interface) has_method(name string) bool {
for method in i.methods {
for mut method in unsafe { i.methods } {
if method.name == name {
return true
}
@ -1308,7 +1308,7 @@ pub fn (i &Interface) has_method(name string) bool {
}
pub fn (s Struct) find_field(name string) ?StructField {
for field in s.fields {
for mut field in unsafe { s.fields } {
if field.name == name {
return field
}
@ -1324,7 +1324,7 @@ pub fn (s Struct) get_field(name string) StructField {
}
pub fn (s &SumType) find_field(name string) ?StructField {
for field in s.fields {
for mut field in unsafe { s.fields } {
if field.name == name {
return field
}
@ -1333,7 +1333,7 @@ pub fn (s &SumType) find_field(name string) ?StructField {
}
pub fn (i Interface) defines_method(name string) bool {
for method in i.methods {
for mut method in unsafe { i.methods } {
if method.name == name {
return true
}