aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrançois Rey2012-08-06 12:31:10 (EDT)
committerFrançois Rey2012-08-06 12:31:10 (EDT)
commit09f5894323514c1b0736d8cd3639d80636b3c975 (patch)
tree0a536a80947053ccaf8245685b7e4cf8859427bf
parent3e8140d09d2bd7061d5e07129f6631ee09fd7e5e (diff)
downloadegit-09f5894323514c1b0736d8cd3639d80636b3c975.zip
egit-09f5894323514c1b0736d8cd3639d80636b3c975.tar.gz
egit-09f5894323514c1b0736d8cd3639d80636b3c975.tar.bz2
Optimize GitScopeOperation with shorter and faster code.refs/changes/08/7108/3
Shortened and made code faster by removing the use of |= because it's not lazy as the || operator. Change-Id: If3fb180a170a8e8e0585484024569b5ef8705427 Signed-off-by: François Rey <eclipse.org@francois.rey.name>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeOperation.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeOperation.java
index 8633045..355a581 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeOperation.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/operations/GitScopeOperation.java
@@ -67,14 +67,9 @@ public class GitScopeOperation extends ModelOperation {
protected boolean promptForInputChange(String requestPreviewMessage,
IProgressMonitor monitor) {
List<IResource> relevantResources = getRelevantResources();
- boolean showPrompt = false;
-
for (IResource resource : relevantResources)
- showPrompt |= hasChanged(resource);
-
- if(showPrompt)
+ if (hasChanged(resource))
return super.promptForInputChange(requestPreviewMessage, monitor);
-
return false;
}
@@ -86,11 +81,11 @@ public class GitScopeOperation extends ModelOperation {
Status repoStatus = new Git(repository).status().call();
String path = resource.getFullPath().removeFirstSegments(1)
.toOSString();
- hasChanged |= repoStatus.getAdded().contains(path);
- hasChanged |= repoStatus.getChanged().contains(path);
- hasChanged |= repoStatus.getModified().contains(path);
- hasChanged |= repoStatus.getRemoved().contains(path);
- hasChanged |= repoStatus.getUntracked().contains(path);
+ hasChanged = repoStatus.getAdded().contains(path)
+ || repoStatus.getChanged().contains(path)
+ || repoStatus.getModified().contains(path)
+ || repoStatus.getRemoved().contains(path)
+ || repoStatus.getUntracked().contains(path);
} catch (Exception e) {
Activator.logError(UIText.GitScopeOperation_couldNotDetermineState,
e);