1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

bug 279844: Slow algorithm for checking duplicate path entries

Patch from David Dubrow
This commit is contained in:
Andrew Gvozdev 2009-09-02 00:40:23 +00:00
parent e69c7e2846
commit c3704262e9
2 changed files with 23 additions and 12 deletions

View file

@ -92,6 +92,18 @@ public final class CLibraryFileEntry extends ACPathEntry implements
return fSourceAttachmentRootPath; return fSourceAttachmentRootPath;
} }
@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 @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if(other == this) if(other == this)

View file

@ -1793,14 +1793,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
newEntries = EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY; 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. // Check the removed entries.
for (int i = 0; i < oldEntries.length; i++) { for (ICLanguageSettingEntry oldEntry : oldEntries) {
boolean found = false; boolean found = false;
for (int j = 0; j < newEntries.length; j++) { if (newEntrySet.contains(oldEntry)) {
if (oldEntries[i].equals(newEntries[j])) { found = true;
found = true; break;
break;
}
} }
if(!found){ if(!found){
result[1] = true; result[1] = true;
@ -1809,13 +1810,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
// Check the new entries. // Check the new entries.
for (int i = 0; i < newEntries.length; i++) { for (ICLanguageSettingEntry newEntry : newEntries) {
boolean found = false; boolean found = false;
for (int j = 0; j < oldEntries.length; j++) { if (oldEntrySet.contains(newEntry)) {
if (newEntries[i].equals(oldEntries[j])) { found = true;
found = true; break;
break;
}
} }
if(!found){ if(!found){
result[0] = true; result[0] = true;