From f4087a09fc43eaa905e8e47fed752ac2a7faae0d Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 1 Feb 2008 15:31:10 +0000 Subject: [PATCH] Performance improvement for path entry comparison --- .../cdt/internal/core/model/APathEntry.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java index f97838d6159..fd1cf476c0e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 QNX Software Systems and others. + * Copyright (c) 2000, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -96,9 +96,16 @@ public abstract class APathEntry extends PathEntry { return false; } - Set excludeSet = new HashSet(); - Set otherSet = new HashSet(); - for (int i = 0; i < excludeLength; i++) { + int i=0; + // performance: iterate to first non-identical path + for (; i < excludeLength; i++) { + if (exclusionPatterns[i] == otherExcludes[i]) { + continue; + } + } + Set excludeSet = new HashSet(); + Set otherSet = new HashSet(); + for (; i < excludeLength; i++) { // compare toStrings instead of IPaths // since IPath.equals is specified to ignore trailing separators excludeSet.add(exclusionPatterns[i].toString());