Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » HashTableOf[X](Legacy code?)
HashTableOf[X] [message #1142043] Thu, 17 October 2013 11:10 Go to next message
Nikolay Metchev is currently offline Nikolay MetchevFriend
Messages: 15
Registered: July 2009
Junior Member
Hello Everyone,
I have been looking around the code in Eclipse source code and have come across something quite strange:
There seems to be a whole bunch of HashTableOf[X] classes in the org.eclipse.jdt.internal.compiler.util package. I am trying to figure out if the code would benefit by replacing them with a normal java.util.HashMap.
In particular I can't see any benefit of HashTableOfObject over HashMap - containsKey() in particular is O(N) rather then O(1). I suppose the primitive versions such as HashTableOfInt avoids boxing but I am not sure this was the thinking when they were created.

Another worrying thing is that they are located in the compiler.util package but they seem to be used all over the place (outside the scope of the compiler).

Any thoughts?
Re: HashTableOf[X] [message #1142360 is a reply to message #1142043] Thu, 17 October 2013 15:18 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I haven't been around when those classes were introduced, but one obvious reason for these classes is:
JDT/Core is compiled at Java source level 1.3 and hence cannot use generics. Those classes provide a type-safe workaround.

As for performance, I *believe* that considerations have been made that a simpler implementation may actually perform better for small numbers of entries, but it may be well invested time to perform some measurements.

Concerning scoping: since the compiler is also packaged standalone, everything needed by the compiler must be defined in this module. The reverse direction doesn't have any such restrictions.

Thanks,
Stephan
Re: HashTableOf[X] [message #1142376 is a reply to message #1142360] Thu, 17 October 2013 15:30 Go to previous message
Nikolay Metchev is currently offline Nikolay MetchevFriend
Messages: 15
Registered: July 2009
Junior Member
Upon closer inspection it seems I misinterpreted the HashtableOfObject.containsKey() code. It is O(1).

I guess I should try and write some tests to see how the performance compares.
Previous Topic:Spell Checker for Eclipse Custom Editor
Next Topic:[SOLVED] Cannot run JUnit Plug-in Tests on Linux
Goto Forum:
  


Current Time: Fri Apr 26 11:16:47 GMT 2024

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

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

Back to the top