Commit 97bb710f authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

gsymbol: improve performance on find()

Vala Symbol.Scope.lookup() is much faster than get the
symbol table, because non-GObject ref and unref operations.
parent ec554019
......@@ -18,6 +18,7 @@
using GVls;
using Vala;
using Gee;
using GLib;
public class GVls.GSymbol : Gee.AbstractMap<string,GVls.Symbol>,
GLib.ListModel,
......@@ -194,28 +195,25 @@ public class GVls.GSymbol : Gee.AbstractMap<string,GVls.Symbol>,
}
public override Symbol get (string key) {
if (_symbol.scope != null) {
var symt = _symbol.scope.get_symbol_table ();
if (symt != null) {
var v = symt.get (key);
if (v != null) {
_current = new GSymbol (v, _file) as Symbol;
return _current;
} else {
switch (symbol_kind) {
case SymbolKind.CLASS:
case SymbolKind.INTERFACE:
// FIXME: Maybe using current location can help to get faster a symbol in a Block
foreach (Vala.Method m in (_symbol as ObjectTypeSymbol).get_methods ()) {
if (m.body != null) {
var sr = block_find_symbol (m.body, key);
if (sr != null) {
_current = new GSymbol (sr, _file) as Symbol;
return _current;
}
var v = _symbol.scope.lookup (key);
if (v != null) {
_current = new GSymbol (v, _file) as Symbol;
return _current;
} else {
switch (symbol_kind) {
case SymbolKind.CLASS:
case SymbolKind.INTERFACE:
// FIXME: Maybe using current location can help to get faster a symbol in a Block
foreach (Vala.Method m in (_symbol as ObjectTypeSymbol).get_methods ()) {
if (m.body != null) {
var sr = block_find_symbol (m.body, key);
if (sr != null) {
_current = new GSymbol (sr, _file) as Symbol;
return _current;
}
}
break;
}
}
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment