You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find that the private field hasAnnotations at Line 287 in the file 'guice/core/src/com/google/inject/internal/Annotations.java ' on the master branch is only assigned and used in the field cache. Therefore, this field can be removed from the class, and become an input parameter in the field cache. This transformation will normally reduce memory usage and improve readability of your code.I will be happy if this transformation is helpful.
// line 287 this field can be removed from the classprivateCacheLoader<Class<? extendsAnnotation>, Boolean> hasAnnotations =
newCacheLoader<Class<? extendsAnnotation>, Boolean>() {
@OverridepublicBooleanload(Class<? extendsAnnotation> annotationType) {
for (Annotationannotation : annotationType.getAnnotations()) {
if (annotationTypes.contains(annotation.annotationType())) {
returntrue;
}
}
returnfalse;
}
};
// start finalLoadingCache<Class<? extendsAnnotation>, Boolean> cache =
CacheBuilder.newBuilder().weakKeys().build(newCacheLoader<Class<? extendsAnnotation>, Boolean>() {
@OverridepublicBooleanload(Class<? extendsAnnotation> annotationType) {
for (Annotationannotation : annotationType.getAnnotations()) {
if (annotationTypes.contains(annotation.annotationType())) {
returntrue;
}
}
returnfalse;
}
});
// endfinalLoadingCache<Class<? extendsAnnotation>, Boolean> cache =
CacheBuilder.newBuilder().weakKeys().build(hasAnnotations);
The text was updated successfully, but these errors were encountered:
Hi,
I find that the private field hasAnnotations at Line 287 in the file 'guice/core/src/com/google/inject/internal/Annotations.java ' on the master branch is only assigned and used in the field cache. Therefore, this field can be removed from the class, and become an input parameter in the field cache. This transformation will normally reduce memory usage and improve readability of your code.I will be happy if this transformation is helpful.
The text was updated successfully, but these errors were encountered: