Permalink
Browse files

Avoid unnecessary allocations (String and Integer).

  • Loading branch information...
1 parent 920264a commit 75bbf40a7519f267e242f759ede64c36efd04e18 @ijuma ijuma committed Feb 2, 2010
@@ -135,6 +135,6 @@ public int hashCode() {
}
public int compareTo(Node other) {
- return new Integer(this.id).compareTo(other.getId());
+ return Integer.valueOf(this.id).compareTo(other.getId());
}
}
@@ -307,7 +307,7 @@ public static String createReadOnlyIndex(Cluster cluster,
// make a temp dir
File dataDir = new File(baseDir + File.separatorChar + "read-only-temp-index-"
- + new Integer((int) (Math.random() * 1000)));
+ + ((int) (Math.random() * 1000)));
// build and open store
JsonStoreBuilder storeBuilder = new JsonStoreBuilder(jsonReader,
cluster,
@@ -356,7 +356,7 @@ public static int getMissingPartitionsSize(Cluster orig, Cluster updated) {
SortedSet<Integer> bPartitonSet = new TreeSet<Integer>(nodeB.getPartitionIds());
for(int p: nodeA.getPartitionIds()) {
- if(!bPartitonSet.contains(new Integer(p))) {
+ if(!bPartitonSet.contains(p)) {
diffPartition++;
}
}
@@ -72,7 +72,7 @@ public void doOperation(int id) throws Exception {
private static class StringResourceFactory implements ResourceFactory<Integer, String> {
public String create(Integer key) {
- return new String(key + "-val");
+ return key + "-val";
}
public void destroy(Integer key, String obj) {}
@@ -91,7 +91,7 @@ public void passivateObject(Object k, Object v) {}
public void destroyObject(Object k, Object v) {}
public Object makeObject(Object k) {
- return new String(k + "-val");
+ return k + "-val";
}
public boolean validateObject(Object k, Object v) {
@@ -11,7 +11,7 @@
return new ResourceFactory<String, String>() {
public String create(String key) throws Exception {
- return new String("resource");
+ return "resource";
}
public void destroy(String key, String obj) throws Exception {}

0 comments on commit 75bbf40

Please sign in to comment.