increase cache of stringified longs
This should improve the csv generation a little bit.
This commit is contained in:
@@ -2,21 +2,21 @@ package org.lucares.recommind.logs;
|
||||
|
||||
public class LongUtils {
|
||||
|
||||
private static final int INT_TO_STRING_CACHE_SIZE= 1000;
|
||||
private static final int INT_TO_STRING_CACHE_SIZE = 10_000;
|
||||
private static final String[] INT_TO_STRING;
|
||||
static {
|
||||
|
||||
INT_TO_STRING = new String[INT_TO_STRING_CACHE_SIZE];
|
||||
|
||||
for (int i = 0; i < INT_TO_STRING_CACHE_SIZE; i++){
|
||||
for (int i = 0; i < INT_TO_STRING_CACHE_SIZE; i++) {
|
||||
INT_TO_STRING[i] = String.valueOf(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static String longToString(final long value){
|
||||
public static String longToString(final long value) {
|
||||
// using pre-generated strings reduces memory allocation by up to 25%
|
||||
|
||||
if (value < INT_TO_STRING_CACHE_SIZE){
|
||||
if (value < INT_TO_STRING_CACHE_SIZE) {
|
||||
return INT_TO_STRING[(int) value];
|
||||
}
|
||||
return String.valueOf(value);
|
||||
|
||||
Reference in New Issue
Block a user