Skip to content

Commit

Permalink
refactor: fix some hintbugs warnings (#616)
Browse files Browse the repository at this point in the history
Invocation of toString() on an array
Inefficient use of keySet() iterator instead of values() iterator
Inefficient use of keySet() iterator instead of entrySet() iterator

relates to Fix huntbugs warnings #586
  • Loading branch information
AlexElin authored and vlsi committed Aug 4, 2016
1 parent 22c72b4 commit dd71f6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -976,12 +976,10 @@ public synchronized void insertRow() throws SQLException {
insertSQL.append(paramSQL.toString());
insertStatement = connection.prepareStatement(insertSQL.toString());

Iterator<String> keys = updateValues.keySet().iterator();
Iterator<Object> values = updateValues.values().iterator();

for (int i = 1; keys.hasNext(); i++) {
String key = keys.next();
Object o = updateValues.get(key);
insertStatement.setObject(i, o);
for (int i = 1; values.hasNext(); i++) {
insertStatement.setObject(i, values.next());
}

insertStatement.executeUpdate();
Expand Down Expand Up @@ -1688,10 +1686,10 @@ private void parseQuery() {

private void updateRowBuffer() throws SQLException {

for (String columnName : updateValues.keySet()) {
int columnIndex = findColumn(columnName) - 1;
for (Map.Entry<String, Object> entry : updateValues.entrySet()) {
int columnIndex = findColumn(entry.getKey()) - 1;

Object valueObject = updateValues.get(columnName);
Object valueObject = entry.getValue();
if (valueObject instanceof PGobject) {
String value = ((PGobject) valueObject).getValue();
rowBuffer[columnIndex] = (value == null) ? null : connection.encodeString(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class TimestampUtils {
continue;
}
GMT_ZONES.put(pgZoneName + Math.abs(i), timeZone);
GMT_ZONES.put(pgZoneName + NUMBERS[Math.abs(i)], timeZone);
GMT_ZONES.put(pgZoneName + new String(NUMBERS[Math.abs(i)]), timeZone);
}
// Fast path to getting the default timezone.
// Accessing the default timezone over and over creates a clone with regular API.
Expand Down

0 comments on commit dd71f6f

Please sign in to comment.