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();
|
return substitute != null ? substitute : super.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public KtExpression getFirstStatement() {
|
||||||
|
return findChildByClass(KtExpression.class);
|
||||||
|
}
|
||||||
|
|
||||||
@ReadOnly
|
@ReadOnly
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<KtExpression> getStatements() {
|
public List<KtExpression> getStatements() {
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ fun KtElement.isFirstStatement(): Boolean {
|
|||||||
element = parent
|
element = parent
|
||||||
parent = parent.parent
|
parent = parent.parent
|
||||||
}
|
}
|
||||||
return parent is KtBlockExpression && parent.children.first { it is KtElement } == element
|
return parent is KtBlockExpression && parent.firstStatement == element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user