mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 04:34:49 +00:00
HHH-7066 byte arrays to String conversion benefits from initial buffer size
This commit is contained in:
parent
98d0b8398d
commit
f51779d2f7
@ -73,9 +73,9 @@ public static String extractString(Reader reader) {
|
||||
*/
|
||||
public static String extractString(Reader reader, int lengthHint) {
|
||||
// read the Reader contents into a buffer and return the complete string
|
||||
final StringBuilder stringBuilder = new StringBuilder( lengthHint );
|
||||
try {
|
||||
final int bufferSize = Math.min( lengthHint, 2048 );
|
||||
final StringBuilder stringBuilder = new StringBuilder( bufferSize );
|
||||
try {
|
||||
char[] buffer = new char[bufferSize];
|
||||
while (true) {
|
||||
int amountRead = reader.read( buffer, 0, bufferSize );
|
||||
|
@ -62,7 +62,7 @@ public int extractHashCode(byte[] bytes) {
|
||||
}
|
||||
|
||||
public String toString(byte[] bytes) {
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
final StringBuilder buf = new StringBuilder( bytes.length * 2 );
|
||||
for ( byte aByte : bytes ) {
|
||||
final String hexStr = Integer.toHexString( aByte - Byte.MIN_VALUE );
|
||||
if ( hexStr.length() == 1 ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user