Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2009-09-01 20:43:10 -0400
committerAndrew Gvozdev2009-09-01 20:43:10 -0400
commitdb47eeb81844785381c1c875eaa4385f80f99f49 (patch)
tree2046d8389b7fcc04fbf080b3c3dc77d537a4b2bf
parentb996a21d7dfb60680216bbe355010d98d03fe299 (diff)
downloadorg.eclipse.cdt-db47eeb81844785381c1c875eaa4385f80f99f49.tar.gz
org.eclipse.cdt-db47eeb81844785381c1c875eaa4385f80f99f49.tar.xz
org.eclipse.cdt-db47eeb81844785381c1c875eaa4385f80f99f49.zip
bug 279844: Slow algorithm for checking duplicate path entries
Patch from David Dubrow
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java12
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java23
2 files changed, 23 insertions, 12 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java
index 9ebe581e65..d7ec4873b2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CLibraryFileEntry.java
@@ -93,6 +93,18 @@ public final class CLibraryFileEntry extends ACPathEntry implements
}
@Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fSourceAttachmentPath == null) ? 0 : fSourceAttachmentPath.hashCode());
+ result = prime * result
+ + ((fSourceAttachmentPrefixMapping == null) ? 0 : fSourceAttachmentPrefixMapping.hashCode());
+ result = prime * result
+ + ((fSourceAttachmentRootPath == null) ? 0 : fSourceAttachmentRootPath.hashCode());
+ return result;
+ }
+
+ @Override
public boolean equals(Object other) {
if(other == this)
return true;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
index e537251e6d..2c1d9c1da2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
@@ -1793,14 +1793,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
newEntries = EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY;
}
+ Set<ICLanguageSettingEntry> newEntrySet = new HashSet<ICLanguageSettingEntry>(Arrays.asList(newEntries));
+ Set<ICLanguageSettingEntry> oldEntrySet = new HashSet<ICLanguageSettingEntry>(Arrays.asList(oldEntries));
+
// Check the removed entries.
- for (int i = 0; i < oldEntries.length; i++) {
+ for (ICLanguageSettingEntry oldEntry : oldEntries) {
boolean found = false;
- for (int j = 0; j < newEntries.length; j++) {
- if (oldEntries[i].equals(newEntries[j])) {
- found = true;
- break;
- }
+ if (newEntrySet.contains(oldEntry)) {
+ found = true;
+ break;
}
if(!found){
result[1] = true;
@@ -1809,13 +1810,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
}
// Check the new entries.
- for (int i = 0; i < newEntries.length; i++) {
+ for (ICLanguageSettingEntry newEntry : newEntries) {
boolean found = false;
- for (int j = 0; j < oldEntries.length; j++) {
- if (newEntries[i].equals(oldEntries[j])) {
- found = true;
- break;
- }
+ if (oldEntrySet.contains(newEntry)) {
+ found = true;
+ break;
}
if(!found){
result[0] = true;

Back to the top