Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to order ITypeBindings to increase performance of search of needed class?
How to order ITypeBindings to increase performance of search of needed class? [message #1737833] Wed, 13 July 2016 07:11 Go to next message
Eclipse UserFriend
Hi, I have a static scanner which uses JDT. If I have a method invocation, I open it (actually not everytime, but it doesn't matter). "Open" means that I find CFG of this method in local bundle and perform scanning. And the question is how to optimize searching process.

To find a method, I must have IMethodBinding. Using that binding, I receive ITypeBinding of the declaring class. After I search the class in local bundle:
for(int i = 0; i < sortedClasses.size(); i++) {
	Class clazz = sortedClasses.get(i);
	if(clazz.getClassBinding() != null && clazz.getClassBinding().isEqualTo(classBinding)) {
		return clazz;
	}
}
return null;

But I'm sure it could be done much more faster, but have no idea how.
Let's verify that I cannot use == operator, equals() method, hash codes, only isEqualTo() is allowed to compare bindings. Maybe you have any ideas how to make it better? I mean something like
Map<IBinding, Class> map = ...;
...
ITypeBinding declaringClass = methodBinding.getDeclaringClass();
Class clazz = map.get(declaringClass);

[Updated on: Wed, 13 July 2016 07:15] by Moderator

Re: How to order ITypeBindings to increase performance of search of needed class? [message #1738112 is a reply to message #1737833] Fri, 15 July 2016 15:02 Go to previous message
Eclipse UserFriend
Is "Class" "java.lang.Class"?
What's "clazz.getClassBinding()"?

The javadoc of org.eclipse.jdt.core.dom.IBinding.isEqualTo(IBinding) explains, when this method must be called rather than using "==".

To get a useful key from a binding you may use IBinding.getKey().
Previous Topic:Can't start Eclipse
Next Topic:An internal error occurred during: "Building workspace".
Goto Forum:
  


Current Time: Thu May 15 13:06:50 EDT 2025

Powered by FUDForum. Page generated in 0.03274 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top