[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdev-ruby] duchain: Improve performance of if expression parsing: make it O(n) instead of O(n!),
From: Alexander Dymo <adymo () kdevelop ! org>
Date: 2012-10-23 20:40:42
Message-ID: 20121023204042.8F62BA6078 () git ! kde ! org
[Download RAW message or body]
Git commit 15952d23c5f16e7dbfd83d50c8101f6a12257c69 by Alexander Dymo.
Committed on 23/10/2012 at 22:34.
Pushed by dymo into branch 'master'.
Improve performance of if expression parsing: make it O(n) instead of O(n!),
visitLastStatement is already smart enough to traverse the elsif/else tree,
so there's no need for additional visiting and loop
M +3 -6 duchain/expressionvisitor.cpp
http://commits.kde.org/kdev-ruby/15952d23c5f16e7dbfd83d50c8101f6a12257c69
diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp
index b90f749..0c6256d 100644
--- a/duchain/expressionvisitor.cpp
+++ b/duchain/expressionvisitor.cpp
@@ -309,17 +309,14 @@ void ExpressionVisitor::visitBoolean(RubyAst *)
void ExpressionVisitor::visitIfStatement(RubyAst *node)
{
- RubyAstVisitor::visitIfStatement(node);
Node *aux = node->tree;
node->tree = aux->l;
ExpressionVisitor::visitLastStatement(node);
AbstractType::Ptr res = lastType();
+ node->tree = aux->r;
+ ExpressionVisitor::visitLastStatement(node);
+ res = mergeTypes(res, lastType());
- for (Node *n = aux->r; n != NULL; n = n->r) {
- node->tree = n;
- ExpressionVisitor::visitLastStatement(node);
- res = mergeTypes(res, lastType());
- }
encounter(res);
node->tree = aux;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic