Skip to content

Commit b145a83

Browse files
harshmoorjanimarcosnils
authored andcommitted
Added initial size (and load factor) for HashMaps - to avoid it being resized when Redis Hash has too many keys. (#1343)
1 parent 69d4080 commit b145a83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/redis/clients/jedis/BuilderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public String toString() {
9797
@SuppressWarnings("unchecked")
9898
public Map<String, String> build(Object data) {
9999
final List<byte[]> flatHash = (List<byte[]>) data;
100-
final Map<String, String> hash = new HashMap<String, String>();
100+
final Map<String, String> hash = new HashMap<String, String>(flatHash.size()/2, 1);
101101
final Iterator<byte[]> iterator = flatHash.iterator();
102102
while (iterator.hasNext()) {
103103
hash.put(SafeEncoder.encode(iterator.next()), SafeEncoder.encode(iterator.next()));
@@ -117,7 +117,7 @@ public String toString() {
117117
@SuppressWarnings("unchecked")
118118
public Map<String, String> build(Object data) {
119119
final List<Object> flatHash = (List<Object>) data;
120-
final Map<String, String> hash = new HashMap<String, String>();
120+
final Map<String, String> hash = new HashMap<String, String>(flatHash.size()/2, 1);
121121
final Iterator<Object> iterator = flatHash.iterator();
122122
while (iterator.hasNext()) {
123123
hash.put(SafeEncoder.encode((byte[]) iterator.next()),

0 commit comments

Comments
 (0)