remove extra array allocation

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1180469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-10-08 19:19:02 +00:00
parent bee60b6144
commit a2936360e9
1 changed files with 9 additions and 7 deletions

View File

@ -368,27 +368,29 @@ public class TrieField extends org.apache.solr.schema.FieldType {
@Override
public CharsRef indexedToReadable(BytesRef indexedForm, CharsRef charsRef) {
final char[] value;
final String value;
switch (type) {
case INTEGER:
value = Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) ).toCharArray();
value = Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) );
break;
case FLOAT:
value = Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) ).toCharArray();
value = Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) );
break;
case LONG:
value = Long.toString( NumericUtils.prefixCodedToLong(indexedForm) ).toCharArray();
value = Long.toString( NumericUtils.prefixCodedToLong(indexedForm) );
break;
case DOUBLE:
value = Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) ).toCharArray();
value = Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) );
break;
case DATE:
value = dateField.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ).toCharArray();
value = dateField.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) );
break;
default:
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
}
charsRef.copy(value, 0, value.length);
charsRef.grow(value.length());
charsRef.length = value.length();
value.getChars(0, charsRef.length, charsRef.chars, 0);
return charsRef;
}