1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Minor performance optimization.

This commit is contained in:
Sergey Prigogin 2014-04-16 21:13:19 -07:00
parent d199768e64
commit ede42e1820

View file

@ -242,7 +242,11 @@ public abstract class ASTNode implements IASTNode {
@Override
public IASTTranslationUnit getTranslationUnit() {
return parent != null ? parent.getTranslationUnit() : null;
IASTNode node = this;
for (IASTNode p = parent; p != null; p = p.getParent()) {
node = p;
}
return node instanceof IASTTranslationUnit ? (IASTTranslationUnit) node : null;
}
@Override