### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/index/DiskIndex.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DiskIndex.java,v retrieving revision 1.54 diff -u -r1.54 DiskIndex.java --- search/org/eclipse/jdt/internal/core/index/DiskIndex.java 11 Jan 2007 11:45:16 -0000 1.54 +++ search/org/eclipse/jdt/internal/core/index/DiskIndex.java 18 Jan 2007 19:10:46 -0000 @@ -19,6 +19,7 @@ import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; import org.eclipse.jdt.internal.compiler.util.SimpleSet; +import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray; public class DiskIndex { @@ -45,6 +46,8 @@ private static final int CHUNK_SIZE = 100; +private static final SimpleSetOfCharArray INTERNED_CATEGORY_NAMES = new SimpleSetOfCharArray(20); + static class IntList { int size; @@ -487,8 +490,7 @@ for (int i = 0, l = names.length; i < l; i++) if (names[i] != null) newDiskIndex.copyQueryResults( - (HashtableOfObject) memoryIndex.docsToReferences.get(names[i]), - ((Integer) integerPositions[i]).intValue()); + (HashtableOfObject) memoryIndex.docsToReferences.get(names[i]), ((Integer) integerPositions[i]).intValue()); } indexedDocuments = null; // free up the space @@ -615,7 +617,7 @@ categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file } } - this.categoryTables.put(categoryName, categoryTable); + this.categoryTables.put(INTERNED_CATEGORY_NAMES.get(categoryName), categoryTable); // cache the table as long as its not too big // in practice, some tables can be greater than 500K when they contain more than 10K elements this.cachedCategoryName = categoryTable.elementSize < 10000 ? categoryName : null; @@ -733,7 +735,7 @@ int size = file.readInt(); this.categoryOffsets = new HashtableOfIntValues(size); for (int i = 0; i < size; i++) - this.categoryOffsets.put(Util.readUTF(file), file.readInt()); // cache offset to category table + this.categoryOffsets.put(INTERNED_CATEGORY_NAMES.get(Util.readUTF(file)), file.readInt()); // cache offset to category table this.categoryTables = new HashtableOfObject(3); } synchronized void startQuery() { Index: compiler/org/eclipse/jdt/internal/compiler/util/SimpleSetOfCharArray.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleSetOfCharArray.java,v retrieving revision 1.1 diff -u -r1.1 SimpleSetOfCharArray.java --- compiler/org/eclipse/jdt/internal/compiler/util/SimpleSetOfCharArray.java 3 Nov 2006 12:52:17 -0000 1.1 +++ compiler/org/eclipse/jdt/internal/compiler/util/SimpleSetOfCharArray.java 18 Jan 2007 19:10:46 -0000 @@ -76,6 +76,21 @@ return result; } +public char[] get(char[] object) { + int length = this.values.length; + int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length; + char[] current; + while ((current = this.values[index]) != null) { + if (CharOperation.equals(current, object)) return current; + if (++index == length) index = 0; + } + this.values[index] = object; + + // assumes the threshold is never equal to the size of the table + if (++this.elementSize > this.threshold) rehash(); + return object; +} + public boolean includes(char[] object) { int length = values.length; int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;