Fix performance regression caused by contracts
Do not obtain all children from KtBlockExpression when you only need the first one. It might be crucial for a huge blocks of code
This commit is contained in:
@@ -123,6 +123,11 @@ public class KtBlockExpression extends LazyParseablePsiElement implements KtElem
|
||||
return substitute != null ? substitute : super.getParent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtExpression getFirstStatement() {
|
||||
return findChildByClass(KtExpression.class);
|
||||
}
|
||||
|
||||
@ReadOnly
|
||||
@NotNull
|
||||
public List<KtExpression> getStatements() {
|
||||
|
||||
@@ -323,7 +323,7 @@ fun KtElement.isFirstStatement(): Boolean {
|
||||
element = parent
|
||||
parent = parent.parent
|
||||
}
|
||||
return parent is KtBlockExpression && parent.children.first { it is KtElement } == element
|
||||
return parent is KtBlockExpression && parent.firstStatement == element
|
||||
}
|
||||
|
||||
|
||||
@@ -671,4 +671,4 @@ fun KtExpression.topParenthesizedParentOrMe(): KtExpression {
|
||||
result = result.parent.safeAs() ?: break
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user