Skip to content

Commit 60a27e1

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 5dd5e05 commit 60a27e1

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
@@ -90,7 +90,7 @@ public String toString() {
9090
@SuppressWarnings("unchecked")
9191
public Map<String, String> build(Object data) {
9292
final List<byte[]> flatHash = (List<byte[]>) data;
93-
final Map<String, String> hash = new HashMap<String, String>();
93+
final Map<String, String> hash = new HashMap<String, String>(flatHash.size()/2, 1);
9494
final Iterator<byte[]> iterator = flatHash.iterator();
9595
while (iterator.hasNext()) {
9696
hash.put(SafeEncoder.encode(iterator.next()), SafeEncoder.encode(iterator.next()));
@@ -109,7 +109,7 @@ public String toString() {
109109
@SuppressWarnings("unchecked")
110110
public Map<String, String> build(Object data) {
111111
final List<Object> flatHash = (List<Object>) data;
112-
final Map<String, String> hash = new HashMap<String, String>();
112+
final Map<String, String> hash = new HashMap<String, String>(flatHash.size()/2, 1);
113113
final Iterator<Object> iterator = flatHash.iterator();
114114
while (iterator.hasNext()) {
115115
hash.put(SafeEncoder.encode((byte[]) iterator.next()),

0 commit comments

Comments
 (0)