small performance fixes : unnecessary unboxing operations removed

Motivation :

Unboxing operations allocate unnecessary objects when it could be avoided.

Modifications:
Replaced Float.valueOf with Number.parseFloat where possible.

Result:

Less unnecessary objects allocations.
This commit is contained in:
Dmitriy Dumanskiy 2016-08-01 00:20:45 +03:00 committed by Norman Maurer
parent e85d437398
commit a4d8f930af
2 changed files with 5 additions and 5 deletions

View File

@ -141,7 +141,7 @@ public class HttpContentCompressor extends HttpContentEncoder {
int equalsPos = encoding.indexOf('='); int equalsPos = encoding.indexOf('=');
if (equalsPos != -1) { if (equalsPos != -1) {
try { try {
q = Float.valueOf(encoding.substring(equalsPos + 1)); q = Float.parseFloat(encoding.substring(equalsPos + 1));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// Ignore encoding // Ignore encoding
q = 0.0f; q = 0.0f;

View File

@ -82,7 +82,7 @@ public class CharSequenceValueConverter implements ValueConverter<CharSequence>
if (value instanceof AsciiString) { if (value instanceof AsciiString) {
return ((AsciiString) value).byteAt(0); return ((AsciiString) value).byteAt(0);
} }
return Byte.valueOf(value.toString()); return Byte.parseByte(value.toString());
} }
@Override @Override
@ -100,7 +100,7 @@ public class CharSequenceValueConverter implements ValueConverter<CharSequence>
if (value instanceof AsciiString) { if (value instanceof AsciiString) {
return ((AsciiString) value).parseShort(); return ((AsciiString) value).parseShort();
} }
return Short.valueOf(value.toString()); return Short.parseShort(value.toString());
} }
@Override @Override
@ -139,7 +139,7 @@ public class CharSequenceValueConverter implements ValueConverter<CharSequence>
if (value instanceof AsciiString) { if (value instanceof AsciiString) {
return ((AsciiString) value).parseFloat(); return ((AsciiString) value).parseFloat();
} }
return Float.valueOf(value.toString()); return Float.parseFloat(value.toString());
} }
@Override @Override
@ -147,6 +147,6 @@ public class CharSequenceValueConverter implements ValueConverter<CharSequence>
if (value instanceof AsciiString) { if (value instanceof AsciiString) {
return ((AsciiString) value).parseDouble(); return ((AsciiString) value).parseDouble();
} }
return Double.valueOf(value.toString()); return Double.parseDouble(value.toString());
} }
} }