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

parser: small optimizations

This commit is contained in:
Alexander Medvednikov
2019-08-26 00:08:06 +03:00
parent 794cd561cd
commit 76a89c832e
3 changed files with 15 additions and 10 deletions

View File

@ -320,6 +320,10 @@ fn (table &Table) known_type(typ_ string) bool {
return t.name.len > 0 && !t.is_placeholder
}
fn (table &Table) known_type_fast(t &Type) bool {
return t.name.len > 0 && !t.is_placeholder
}
fn (t &Table) find_fn(name string) Fn {
f := t.fns[name]
if !isnil(f.name.str) {
@ -345,7 +349,7 @@ fn (t mut Table) register_type(typ string) {
}
if typ in t.typesmap {
return
}
}
t.typesmap[typ] = Type{name:typ}
}
@ -684,6 +688,7 @@ fn (t &Table) main_exists() bool {
// TODO use `?Var`
fn (t &Table) find_const(name string) Var {
//println('find const l=$t.consts.len')
for c in t.consts {
if c.name == name {
return c