Mercurial > hg > monetdb-java
diff src/main/java/org/monetdb/jdbc/MonetStatement.java @ 480:849af4b76b28
Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 10 Jun 2021 20:43:16 +0200 (2021-06-10) |
parents | 3dfcd06fd8ba |
children | 6aa38e8c0f2d |
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetStatement.java @@ -206,7 +206,10 @@ public class MonetStatement // copy contents of long[] into new int[] final int[] counts = new int[ret.length]; for (int i = 0; i < ret.length; i++) { - counts[i] = (ret[i] >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int)ret[i]; + if (ret[i] >= Integer.MAX_VALUE) + counts[i] = Integer.MAX_VALUE; + else + counts[i] = (int)ret[i]; } return counts; } @@ -776,10 +779,9 @@ public class MonetStatement */ @Override public ResultSet getResultSet() throws SQLException { - return (header != null && header instanceof MonetConnection.ResultSetResponse) - ? new MonetResultSet(this, - (MonetConnection.ResultSetResponse)header) - : null; + if (header != null && header instanceof MonetConnection.ResultSetResponse) + return new MonetResultSet(this, (MonetConnection.ResultSetResponse)header); + return null; } /** @@ -1111,17 +1113,16 @@ public class MonetStatement * @throws SQLException if a database access error occurs or this * method is called on a closed Statement */ + @Override public long getLargeUpdateCount() throws SQLException { - long ret = -1; if (header != null) { if (header instanceof MonetConnection.UpdateResponse) { - ret = ((MonetConnection.UpdateResponse)header).count; + return ((MonetConnection.UpdateResponse)header).count; } else if (header instanceof MonetConnection.SchemaResponse) { - ret = ((MonetConnection.SchemaResponse)header).state; + return ((MonetConnection.SchemaResponse)header).state; } } - - return ret; + return -1; } /** @@ -1570,9 +1571,7 @@ final class MonetVirtualResultSet extend */ @Override public void close() { - if (!closed) { - closed = true; - // types and columns are MonetResultSets private parts - } + closed = true; + // types and columns are MonetResultSets private parts } }