View | Details | Raw Unified | Return to bug 138309 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/index/DiskIndex.java (-4 / +6 lines)
Lines 19-24 Link Here
19
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
19
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
20
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
20
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
21
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
21
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
22
import org.eclipse.jdt.internal.compiler.util.SimpleSetOfCharArray;
22
23
23
public class DiskIndex {
24
public class DiskIndex {
24
25
Lines 45-50 Link Here
45
46
46
private static final int CHUNK_SIZE = 100;
47
private static final int CHUNK_SIZE = 100;
47
48
49
private static final SimpleSetOfCharArray INTERNED_CATEGORY_NAMES = new SimpleSetOfCharArray(20);
50
48
static class IntList {
51
static class IntList {
49
52
50
int size;
53
int size;
Lines 487-494 Link Here
487
				for (int i = 0, l = names.length; i < l; i++)
490
				for (int i = 0, l = names.length; i < l; i++)
488
					if (names[i] != null)
491
					if (names[i] != null)
489
						newDiskIndex.copyQueryResults(
492
						newDiskIndex.copyQueryResults(
490
							(HashtableOfObject) memoryIndex.docsToReferences.get(names[i]),
493
							(HashtableOfObject) memoryIndex.docsToReferences.get(names[i]), ((Integer) integerPositions[i]).intValue());
491
							((Integer) integerPositions[i]).intValue());
492
			}
494
			}
493
			indexedDocuments = null; // free up the space
495
			indexedDocuments = null; // free up the space
494
496
Lines 615-621 Link Here
615
				categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file
617
				categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file
616
			}
618
			}
617
		}
619
		}
618
		this.categoryTables.put(categoryName, categoryTable);
620
		this.categoryTables.put(INTERNED_CATEGORY_NAMES.get(categoryName), categoryTable);
619
		// cache the table as long as its not too big
621
		// cache the table as long as its not too big
620
		// in practice, some tables can be greater than 500K when they contain more than 10K elements
622
		// in practice, some tables can be greater than 500K when they contain more than 10K elements
621
		this.cachedCategoryName = categoryTable.elementSize < 10000 ? categoryName : null;
623
		this.cachedCategoryName = categoryTable.elementSize < 10000 ? categoryName : null;
Lines 733-739 Link Here
733
	int size = file.readInt();
735
	int size = file.readInt();
734
	this.categoryOffsets = new HashtableOfIntValues(size);
736
	this.categoryOffsets = new HashtableOfIntValues(size);
735
	for (int i = 0; i < size; i++)
737
	for (int i = 0; i < size; i++)
736
		this.categoryOffsets.put(Util.readUTF(file), file.readInt()); // cache offset to category table
738
		this.categoryOffsets.put(INTERNED_CATEGORY_NAMES.get(Util.readUTF(file)), file.readInt()); // cache offset to category table
737
	this.categoryTables = new HashtableOfObject(3);
739
	this.categoryTables = new HashtableOfObject(3);
738
}
740
}
739
synchronized void startQuery() {
741
synchronized void startQuery() {
(-)compiler/org/eclipse/jdt/internal/compiler/util/SimpleSetOfCharArray.java (+15 lines)
Lines 76-81 Link Here
76
	return result;
76
	return result;
77
}
77
}
78
78
79
public char[] get(char[] object) {
80
	int length = this.values.length;
81
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
82
	char[] current;
83
	while ((current = this.values[index]) != null) {
84
		if (CharOperation.equals(current, object)) return current;
85
		if (++index == length) index = 0;
86
	}
87
	this.values[index] = object;
88
89
	// assumes the threshold is never equal to the size of the table
90
	if (++this.elementSize > this.threshold) rehash();
91
	return object;
92
}
93
79
public boolean includes(char[] object) {
94
public boolean includes(char[] object) {
80
	int length = values.length;
95
	int length = values.length;
81
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;
96
	int index = (CharOperation.hashCode(object) & 0x7FFFFFFF) % length;

Return to bug 138309