Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Refine hash map initial sizing. Use ROOT locale for field names.

[#636][closes #640]
  • Loading branch information
mp911de committed Feb 28, 2024
1 parent 079b565 commit e8a26c5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/io/r2dbc/postgresql/PostgresqlRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import io.r2dbc.postgresql.message.backend.RowDescription;
import io.r2dbc.postgresql.util.Assert;
import io.r2dbc.spi.Row;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import reactor.core.publisher.Mono;
import reactor.util.annotation.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;

Expand Down Expand Up @@ -144,9 +144,9 @@ public String toString() {
}

static Map<String, Integer> createColumnNameIndexMap(List<RowDescription.Field> fields) {
Map<String, Integer> columnNameIndexMap = new HashMap<>(fields.size() * 2);
Map<String, Integer> columnNameIndexMap = new HashMap<>(fields.size(), 1);
for (int i = fields.size() - 1; i >= 0; i--) {
columnNameIndexMap.put(fields.get(i).getName().toLowerCase(Locale.US), i);
columnNameIndexMap.put(fields.get(i).getName().toLowerCase(Locale.ROOT), i);
}

return columnNameIndexMap;
Expand Down Expand Up @@ -188,7 +188,7 @@ private int getColumn(String name) {
return index;
}

index = this.columnNameIndexCacheMap.get(name.toLowerCase(Locale.US));
index = this.columnNameIndexCacheMap.get(name.toLowerCase(Locale.ROOT));
if (index != null) {
this.columnNameIndexCacheMap.put(name, index);
return index;
Expand Down

0 comments on commit e8a26c5

Please sign in to comment.