diff options
| author | François Rey | 2012-08-06 16:31:10 +0000 |
|---|---|---|
| committer | François Rey | 2012-08-06 16:31:10 +0000 |
| commit | 09f5894323514c1b0736d8cd3639d80636b3c975 (patch) | |
| tree | 0a536a80947053ccaf8245685b7e4cf8859427bf | |
| parent | 3e8140d09d2bd7061d5e07129f6631ee09fd7e5e (diff) | |
| download | egit-09f5894323514c1b0736d8cd3639d80636b3c975.tar.gz egit-09f5894323514c1b0736d8cd3639d80636b3c975.tar.xz egit-09f5894323514c1b0736d8cd3639d80636b3c975.zip | |
Optimize GitScopeOperation with shorter and faster code.
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.java | 17 |
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 86330451f6..355a58131d 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); |
