* [PATCH JGIT] Inefficient use of keySet iterator instead of entrySet iterator
@ 2009-03-19 9:17 Yann Simon
0 siblings, 0 replies; only message in thread
From: Yann Simon @ 2009-03-19 9:17 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
>From FindBugs:
This method accesses the value of a Map entry, using a key that
was retrieved from a keySet iterator. It is more efficient to use
an iterator on the entrySet of the map, to avoid the Map.get(key)
lookup.
Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
.../src/org/spearce/jgit/lib/ObjectIdMap.java | 5 +++--
.../src/org/spearce/jgit/transport/AmazonS3.java | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
index d3c7f1d..10feaf9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
@@ -183,8 +183,9 @@ public V put(ObjectId key, V value) {
}
public void putAll(Map<? extends ObjectId, ? extends V> arg0) {
- for (ObjectId k : arg0.keySet()) {
- V v=arg0.get(k);
+ for (Map.Entry<? extends ObjectId, ? extends V> entry : arg0.entrySet()) {
+ ObjectId k = entry.getKey();
+ V v=entry.getValue();
put(k,v);
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/AmazonS3.java b/org.spearce.jgit/src/org/spearce/jgit/transport/AmazonS3.java
index 59337f8..3d8bdca 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/AmazonS3.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/AmazonS3.java
@@ -572,9 +572,10 @@ private HttpURLConnection open(final String method, final String bucket,
private void authorize(final HttpURLConnection c) throws IOException {
final Map<String, List<String>> reqHdr = c.getRequestProperties();
final SortedMap<String, String> sigHdr = new TreeMap<String, String>();
- for (final String hdr : reqHdr.keySet()) {
+ for (final Map.Entry<String, List<String>> entry : reqHdr.entrySet()) {
+ final String hdr = entry.getKey();
if (isSignedHeader(hdr))
- sigHdr.put(hdr.toLowerCase(), toCleanString(reqHdr.get(hdr)));
+ sigHdr.put(hdr.toLowerCase(), toCleanString(entry.getValue()));
}
final StringBuilder s = new StringBuilder();
--
1.6.1.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-19 9:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-19 9:17 [PATCH JGIT] Inefficient use of keySet iterator instead of entrySet iterator Yann Simon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).