diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index 687d470018..cddd38413c 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -390,9 +390,9 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl { typ := table.new_type(reg_idx) mut ts := p.table.get_type_symbol(typ) // if methods were declared before, it's an error, ignore them - ts.methods.clear() + ts.methods = []table.Fn{cap:20} // Parse methods - mut methods := []ast.FnDecl{} + mut methods := []ast.FnDecl{cap:20} for p.tok.kind != .rcbr && p.tok.kind != .eof { method_start_pos := p.tok.position() line_nr := p.tok.line_nr @@ -425,7 +425,8 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl { if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr { method.return_type = p.parse_type() } - method.comments = p.eat_comments() + mcomments := p.eat_comments() + method.comments = mcomments methods << method // println('register method $name') return_type_sym := p.table.get_type_symbol(method.return_type)