Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary calls to String copy constructor #14

Merged
merged 2 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,7 @@ void writeNonUnicodeReader(
else
{
// encoding as per collation
streamByteBuffer[charsCopied] = new String(streamCharBuffer[charsCopied] +
streamByteBuffer[charsCopied] = (streamCharBuffer[charsCopied] +
"")
.getBytes(charSet)[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void registerOutParameter(int index, int sqlType) throws SQLServerExcepti
if (2012 == sqlType)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_featureNotSupported"));
Object[] msgArgs = {new String("REF_CURSOR")};
Object[] msgArgs = {"REF_CURSOR"};
SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public String toString()
if (lcpropValue.equals("true")) return true;
if (lcpropValue.equals("false")) return false;
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidBooleanValue"));
Object[] msgArgs = {new String(propName)};
Object[] msgArgs = {propName};
SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
// Adding return false here for compiler's sake, this code is unreachable.
return false;
Expand Down Expand Up @@ -1128,7 +1128,7 @@ Connection connectInternal(Properties propsIn, SQLServerPooledConnection pooledC
else
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidselectMethod"));
Object[] msgArgs = {new String(sPropValue)};
Object[] msgArgs = {sPropValue};
SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
}

Expand All @@ -1142,7 +1142,7 @@ Connection connectInternal(Properties propsIn, SQLServerPooledConnection pooledC
else
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidresponseBuffering"));
Object[] msgArgs = {new String(sPropValue)};
Object[] msgArgs = {sPropValue};
SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, false);
}

Expand Down Expand Up @@ -1779,7 +1779,7 @@ else if(isDBMirroring)
curserverinfo = curserverinfo + currentFOPlaceHolder.getInstanceName();
}
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPartnerConfiguration"));
Object[] msgArgs = { new String(activeConnectionProperties.getProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString())),
Object[] msgArgs = { activeConnectionProperties.getProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString()),
curserverinfo};
terminate(SQLServerException.DRIVER_ERROR_UNSUPPORTED_CONFIG, form.format(msgArgs));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ else if(value.equalsIgnoreCase(ApplicationIntent.READ_WRITE.toString()))
else
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidapplicationIntent"));
Object[] msgArgs = {new String(value)};
Object[] msgArgs = {value};
throw new SQLServerException(null , form.format(msgArgs) , null, 0 , false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private void checkClosed() throws SQLServerException
if (null == metaInfo)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cantIdentifyTableMetadata"));
Object[] msgArgs = {new String(sProcString)};
Object[] msgArgs = {sProcString};
SQLServerException.makeFromDriverError(con, stmtParent, form.format(msgArgs), null, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ private final boolean doPrepExec(TDSWriter tdsWriter, Parameter[] params, boolea
{
// if the error is not no resultset then throw a processings error.
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_processingError"));
Object[] msgArgs = {new String(sqle.getMessage())};
Object[] msgArgs = {sqle.getMessage()};

SQLServerException.makeFromDriverError(connection, this,
form.format(msgArgs), null, true);
Expand Down Expand Up @@ -2338,25 +2338,25 @@ public final void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLExce
/*L0*/ public final int executeUpdate(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "executeUpdate", sql);
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable"));
Object[] msgArgs = {new String("executeUpdate()")};
Object[] msgArgs = {"executeUpdate()"};
throw new SQLServerException(this , form.format(msgArgs), null, 0 , false);
}
/*L0*/ public final boolean execute(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "execute", sql);
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable"));
Object[] msgArgs = {new String("execute()")};
Object[] msgArgs = {"execute()"};
throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false);
}
/*L0*/ public final java.sql.ResultSet executeQuery(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "executeQuery", sql);
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable"));
Object[] msgArgs = {new String("executeQuery()")};
Object[] msgArgs = {"executeQuery()"};
throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false);
}
/*L0*/ public void addBatch(String sql) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "addBatch", sql);
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_cannotTakeArgumentsPreparedOrCallable"));
Object[] msgArgs = {new String("addBatch()")};
Object[] msgArgs = {"addBatch()"};
throw new SQLServerException(this , form.format(msgArgs) , null, 0 , false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public int getSavepointId() throws SQLServerException {
if (sName != null)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_savepointNamed"));
Object[] msgArgs = {new String(sName)};
Object[] msgArgs = {sName};
SQLServerException.makeFromDriverError(con, null, form.format(msgArgs), null, false);
}
return nId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ else if(value.equalsIgnoreCase("adaptive"))
else
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidresponseBuffering"));
Object[] msgArgs = {new String(value)};
Object[] msgArgs = {value};
SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
}
loggerExternal.exiting(getClassNameLogging(), "setResponseBuffering");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private String typeDisplay(int type)
catch (SQLServerException e1)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_failedToCreateXAConnection"));
Object[] msgArgs = {new String(e1.getMessage())};
Object[] msgArgs = {e1.getMessage()};
if (xaLogger.isLoggable(Level.FINER))
xaLogger.finer(toString() + " exception:" + form.format(msgArgs));
SQLServerException.makeFromDriverError(null,null, form.format(msgArgs), null, true);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void execute(DTV dtv, Clob clobValue) throws SQLServerException
catch (UnsupportedEncodingException ex)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS"));
Object[] msgArgs = {new String(ex.getMessage())};
Object[] msgArgs = {ex.getMessage()};
SQLServerException.makeFromDriverError(
conn,
null,
Expand Down Expand Up @@ -2353,7 +2353,7 @@ else if (null != collation &&
catch (UnsupportedEncodingException ex)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS"));
Object[] msgArgs = {new String(ex.getMessage())};
Object[] msgArgs = {ex.getMessage()};
SQLServerException.makeFromDriverError(
con,
null,
Expand Down Expand Up @@ -2642,7 +2642,7 @@ else if (null != collation &&
catch (UnsupportedEncodingException ex)
{
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_encodingErrorWritingTDS"));
Object[] msgArgs = {new String(ex.getMessage())};
Object[] msgArgs = {ex.getMessage()};
SQLServerException.makeFromDriverError(
con,
null,
Expand Down