aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-03-16 15:28:44 (EDT)
committerChris Aniszczyk2010-04-01 13:08:33 (EDT)
commitc3a03ab557517bc1bc3c40797565ba56de0d8aca (patch)
treebbe237c151a4cbbc4f59c43b33e958e2d077705a
parent724ceb01f229990ee9527c237e90dfaf8e06f98d (diff)
downloadegit-c3a03ab557517bc1bc3c40797565ba56de0d8aca.zip
egit-c3a03ab557517bc1bc3c40797565ba56de0d8aca.tar.gz
egit-c3a03ab557517bc1bc3c40797565ba56de0d8aca.tar.bz2
Improved reability of GitProjectData class.refs/changes/62/362/2
Replaced lops based on Iterator and while with foreach loop. Change-Id: I982d807b0e076c7a18ba6b366b7050e4aef7557b Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index a2628b6..f076471 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -225,9 +225,10 @@ public class GitProjectData {
}
}
- final Reference r = repositoryCache.get(gitDir);
- Repository d = r != null ? (Repository) r.get() : null;
- if (d == null) {
+ final Repository d;
+ if (repositoryCache.containsKey(gitDir)) {
+ d = (Repository) repositoryCache.get(gitDir).get();
+ } else {
d = new Repository(gitDir);
repositoryCache.put(gitDir, new WeakReference<Repository>(d));
}
@@ -376,9 +377,8 @@ public class GitProjectData {
final FileOutputStream o = new FileOutputStream(tmp);
try {
final Properties p = new Properties();
- final Iterator i = mappings.iterator();
- while (i.hasNext()) {
- ((RepositoryMapping) i.next()).store(p);
+ for (final RepositoryMapping repoMapping : mappings) {
+ repoMapping.store(p);
}
p.store(o, "GitProjectData"); //$NON-NLS-1$
ok = true;
@@ -417,9 +417,8 @@ public class GitProjectData {
p.load(o);
mappings.clear();
- final Iterator keyItr = p.keySet().iterator();
- while (keyItr.hasNext()) {
- final String key = keyItr.next().toString();
+ for (final Object keyObj : p.keySet()) {
+ final String key = keyObj.toString();
if (RepositoryMapping.isInitialKey(key)) {
mappings.add(new RepositoryMapping(p, key));
}
@@ -434,9 +433,8 @@ public class GitProjectData {
private void remapAll() {
protectedResources.clear();
- final Iterator i = mappings.iterator();
- while (i.hasNext()) {
- map((RepositoryMapping) i.next());
+ for (final RepositoryMapping repoMapping : mappings) {
+ map(repoMapping);
}
}