mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1688736613


##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
     @BooleanOption(displayName="#LBL_UnusedPackagePrivate", 
tooltip="#TP_UnusedPackagePrivate", 
defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
     public static final String DETECT_UNUSED_PACKAGE_PRIVATE = 
"detect.unused.package.private";
 
-    @TriggerTreeKind(Kind.COMPILATION_UNIT)
+    @TriggerTreeKind({
+        //class-like kinds:
+        Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, 
Kind.RECORD,
+        Kind.VARIABLE,
+        Kind.METHOD
+    })
     public static List<ErrorDescription> unused(HintContext ctx) {

Review Comment:
   the method is going to be called a few k times on large files, compared to 
one time before the change. But it seems we are lucky here and a simple 
fast-path is able to get close to the old state:
   
   I added this after `findUnused(...)` which is already caching results 
internally
   ```java
           if (unused.isEmpty()) {
               return null;
           }
   ```
   `null` will lead to the fast path in `CodeHintProviderImpl#createErrors`. 
   
   and we get:
   ```
   FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: 
{time=0.83ms, invocations=6003, cancelled=false}: 
org.netbeans.modules.java.hints.bugs.Unused
   FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint 
processing complete
   ```
   
   At some point we should take a look at this method and check what is causing 
the slowdown there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to