summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2012-09-18 11:15:31 (EDT)
committer John Arthorne2012-09-18 11:15:31 (EDT)
commit1ee7648e5251c89243cc020a6f22e0cf3d1b73cb (patch)
treec54ee7aafe5b3829991aa61f60cde7d0f681262f
parentd538765d1c5f469e7c1153bdaa97979122bfbad6 (diff)
downloadeclipse.platform.resources-1ee7648e5251c89243cc020a6f22e0cf3d1b73cb.zip
eclipse.platform.resources-1ee7648e5251c89243cc020a6f22e0cf3d1b73cb.tar.gz
eclipse.platform.resources-1ee7648e5251c89243cc020a6f22e0cf3d1b73cb.tar.bz2
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java
index a47225a..86183c2 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTreeNode.java
@@ -93,11 +93,12 @@ public abstract class AbstractDataTreeNode {
int resultIndex = 0;
while (oldIndex < oldNodes.length && newIndex < newNodes.length) {
int log2 = 31 - Integer.numberOfLeadingZeros(oldNodes.length - oldIndex);
- if (log2 > 1 && newNodes.length < (oldNodes.length - oldIndex) / log2) {
+ if (log2 > 1 && (newNodes.length - newIndex) <= (oldNodes.length - oldIndex) / log2) {
// We can expect to fare better using binary search. In particular, this will optimize the case of a folder refresh (new linked
// folder with many files in a flat hierarchy), where this is called repeatedly, with oldNodes containing the files added so far,
// and newNodes containing exactly one new node for the next file to be added. The old algorithm has quadratic performance
- // (O((n+1)*n/2); number of string comparisons is the dominating component here), this new algorithm is O(n*log(n)).
+ // (O((n+1)*n/2); number of string comparisons is the dominating component here) in this case; this new algorithm does O(n*log(n))
+ // string comparisons.
String key = newNodes[newIndex].name;
// Figure out where to insert the next new node.
int left = oldIndex;