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
if (getAdapter(IAnnotationAccess.class) instanceof IAnnotationAccessExtension annotationAccessExtension) {
this.annotationAccess= annotationAccessExtension;
} else {
throw new IllegalStateException("annotationAccess must implement IAnnotationAccessExtension"); //$NON-NLS-1$
}
Here getAdapter(Class) is declared to return . With T=IAnnotationAccess a checkcast to the statically known type is correct. I only wonder, if previously implementation of instanceof patterns took care to avoid unnecessary casts, when the only use of that value would undergo a second checkcast immediately after. -.. was any such optimization intended at some point?
"
Also
ref the comment below as well:
public T getAdapter(Class adapter) {
if (adapter == X509Certificate.class && !certificates.isEmpty()) {
if (certificates.get(0) instanceof X509Certificate certificate) {
return adapter.cast(certificate);
}
}
The result of certificates.get(0) gets casted twice.
To check if such an optimization can be implemented
The text was updated successfully, but these errors were encountered:
To check if such an optimization can be implemented
My original question was: "was any such optimization intended at some point?" Meaning: did recent feature work break existing optimization?
There was no optimization intended earlier - the recent work did not break any existing optimization. This issue is to check whether such an optimization can be done without too much hassle. btw, I would rate this a lower prio issue for now
refer @stephan-herrmann 's comment at:
eclipse-platform/eclipse.platform.releng.aggregator#2358 (comment)
"
oking at AnnotationCodeMiningProvider we are talking about this code:
Here getAdapter(Class) is declared to return . With T=IAnnotationAccess a checkcast to the statically known type is correct. I only wonder, if previously implementation of instanceof patterns took care to avoid unnecessary casts, when the only use of that value would undergo a second checkcast immediately after. -.. was any such optimization intended at some point?
"
Also
ref the comment below as well:
public T getAdapter(Class adapter) {
if (adapter == X509Certificate.class && !certificates.isEmpty()) {
if (certificates.get(0) instanceof X509Certificate certificate) {
return adapter.cast(certificate);
}
}
The result of certificates.get(0) gets casted twice.
To check if such an optimization can be implemented
The text was updated successfully, but these errors were encountered: