-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement EnclosedElementsQuery
to improve performance
#10237
Conversation
@Spikhalskiy Can you please try your project with this branch? |
@@ -193,7 +192,7 @@ interface SpecificInterface { | |||
then: | |||
//I ended up going this route because actually calling the methods here would be relying on | |||
//having the target interface in the bytecode of the test | |||
instance.$proxyMethods.length == 1 | |||
instance.$proxyMethods.length == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Groovy test is now the same as the one for Java
@@ -815,7 +815,7 @@ interface MyBean extends GenericInterface, SpecificInterface { | |||
when: | |||
def allMethods = classElement.getEnclosedElements(ElementQuery.ALL_METHODS) | |||
then: | |||
allMethods.size() == 1 | |||
allMethods.size() == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Groovy test is now the same as the one for Java
@@ -561,4 +563,21 @@ public ElementQuery<T> filter(@NonNull Predicate<T> predicate) { | |||
public Result<T> result() { | |||
return this; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could also check the hashcode field for short-circuiting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will be used without a previous hash code check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea probably not
core-processor/src/main/java/io/micronaut/inject/ast/utils/EnclosedElementsQuery.java
Outdated
Show resolved
Hide resolved
if (methodNode.isPrivate() && classNode.isInterface()) { | ||
return false; | ||
} | ||
if (!methodNode.isAbstract() && classNode.isInterface()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont understand this method. private & interface -> abstract? !abstract & interface -> abstract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private methods are never abstract, and the other one is the default method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code says that private interface methods are abstract though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can drop the interface check too i guess
inject-java/src/main/java/io/micronaut/annotation/processing/visitor/JavaClassElement.java
Outdated
Show resolved
Hide resolved
inject-java/src/main/java/io/micronaut/annotation/processing/visitor/JavaClassElement.java
Outdated
Show resolved
Hide resolved
iterator.remove(); | ||
} | ||
} | ||
elements.removeIf(element -> !filter.test(element)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use filter.negate()
Kudos, SonarCloud Quality Gate passed! |
hides
methodShould fix #10145 and also improve KSP performance.