Iteration by entrySet() instead of keySet()

Change-Id: I7d4cbe10e42f6200a119c74982b8d000b3948e4f
This commit is contained in:
alex.ryazantsev
2013-11-05 06:01:29 +04:00
parent de1e455385
commit 9e5f632d0a
5 changed files with 15 additions and 13 deletions

View File

@@ -551,10 +551,10 @@ public class ChangeJson {
Maps.newHashMapWithExpectedSize(labels.size()); Maps.newHashMapWithExpectedSize(labels.size());
if (detailed) { if (detailed) {
for (String name : labels.keySet()) { for (Map.Entry<String, LabelInfo> entry : labels.entrySet()) {
ApprovalInfo ai = approvalInfo(accountId, 0, null); ApprovalInfo ai = approvalInfo(accountId, 0, null);
byLabel.put(name, ai); byLabel.put(entry.getKey(), ai);
labels.get(name).addApproval(ai); entry.getValue().addApproval(ai);
} }
} }
for (PatchSetApproval psa : current.get(accountId)) { for (PatchSetApproval psa : current.get(accountId)) {

View File

@@ -311,8 +311,8 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
MergeFormatter fmt = new MergeFormatter(); MergeFormatter fmt = new MergeFormatter();
Map<String, MergeResult<? extends Sequence>> r = m.getMergeResults(); Map<String, MergeResult<? extends Sequence>> r = m.getMergeResults();
Map<String, ObjectId> resolved = new HashMap<String, ObjectId>(); Map<String, ObjectId> resolved = new HashMap<String, ObjectId>();
for (String path : r.keySet()) { for (Map.Entry<String, MergeResult<? extends Sequence>> entry : r.entrySet()) {
MergeResult<? extends Sequence> p = r.get(path); MergeResult<? extends Sequence> p = entry.getValue();
TemporaryBuffer buf = new TemporaryBuffer.LocalFile(10 * 1024 * 1024); TemporaryBuffer buf = new TemporaryBuffer.LocalFile(10 * 1024 * 1024);
try { try {
fmt.formatMerge(buf, p, "BASE", oursName, theirsName, "UTF-8"); fmt.formatMerge(buf, p, "BASE", oursName, theirsName, "UTF-8");
@@ -320,7 +320,7 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
InputStream in = buf.openInputStream(); InputStream in = buf.openInputStream();
try { try {
resolved.put(path, ins.insert(Constants.OBJ_BLOB, buf.length(), in)); resolved.put(entry.getKey(), ins.insert(Constants.OBJ_BLOB, buf.length(), in));
} finally { } finally {
in.close(); in.close();
} }

View File

@@ -349,8 +349,9 @@ public class PluginLoader implements LifecycleListener {
syncDisabledPlugins(jars); syncDisabledPlugins(jars);
Map<String, File> activePlugins = filterDisabled(jars); Map<String, File> activePlugins = filterDisabled(jars);
for (String name : activePlugins.keySet()) { for (Map.Entry<String, File> entry : activePlugins.entrySet()) {
File jar = activePlugins.get(name); String name = entry.getKey();
File jar = entry.getValue();
FileSnapshot brokenTime = broken.get(name); FileSnapshot brokenTime = broken.get(name);
if (brokenTime != null && !brokenTime.isModified(jar)) { if (brokenTime != null && !brokenTime.isModified(jar)) {
continue; continue;

View File

@@ -186,9 +186,9 @@ public class CommentsTest extends TestCase {
assertNotNull(actual); assertNotNull(actual);
assertEquals(expected.size(), actual.size()); assertEquals(expected.size(), actual.size());
assertEquals(expected.keySet(), actual.keySet()); assertEquals(expected.keySet(), actual.keySet());
for (String filename : expected.keySet()) { for (Map.Entry<String, ArrayList<PatchLineComment>> entry : expected.entrySet()) {
List<PatchLineComment> expectedComments = expected.get(filename); List<PatchLineComment> expectedComments = entry.getValue();
List<CommentInfo> actualComments = actual.get(filename); List<CommentInfo> actualComments = actual.get(entry.getKey());
assertNotNull(actualComments); assertNotNull(actualComments);
assertEquals(expectedComments.size(), actualComments.size()); assertEquals(expectedComments.size(), actualComments.size());
for (int i = 0; i < expectedComments.size(); i++) { for (int i = 0; i < expectedComments.size(); i++) {

View File

@@ -200,8 +200,9 @@ public class SubmoduleSectionParserTest extends LocalDiskRepositoryTestCase {
expect(bbc.getSubsections("submodule")) expect(bbc.getSubsections("submodule"))
.andReturn(sectionsToReturn.keySet()); .andReturn(sectionsToReturn.keySet());
for (final String id : sectionsToReturn.keySet()) { for (Map.Entry<String, SubmoduleSection> entry : sectionsToReturn.entrySet()) {
final SubmoduleSection section = sectionsToReturn.get(id); String id = entry.getKey();
final SubmoduleSection section = entry.getValue();
expect(bbc.getString("submodule", id, "url")).andReturn(section.getUrl()); expect(bbc.getString("submodule", id, "url")).andReturn(section.getUrl());
expect(bbc.getString("submodule", id, "path")).andReturn( expect(bbc.getString("submodule", id, "path")).andReturn(
section.getPath()); section.getPath());