Make LInteger constructor private and use LInteger.valueOf() everywhere, caching common values.

This commit is contained in:
James Roseborough
2007-10-04 17:37:15 +00:00
parent 885397a74c
commit 9dee79cb80
11 changed files with 52 additions and 36 deletions

View File

@@ -107,7 +107,7 @@ public class LoadState {
static LNumber longBitsToLuaNumber( long bits ) {
if ( ( bits & ( ( 1L << 63 ) - 1 ) ) == 0L ) {
return new LInteger( 0 );
return LInteger.valueOf( 0 );
}
int e = (int)((bits >> 52) & 0x7ffL) - 1023;
@@ -118,7 +118,7 @@ public class LoadState {
long intPrecMask = ( 1L << shift ) - 1;
if ( ( f & intPrecMask ) == 0 ) {
int intValue = (int)( f >> shift ) | ( 1 << e );
return new LInteger( ( ( bits >> 63 ) != 0 ) ? -intValue : intValue );
return LInteger.valueOf( ( ( bits >> 63 ) != 0 ) ? -intValue : intValue );
}
}
@@ -129,7 +129,7 @@ public class LoadState {
LNumber loadNumber() throws IOException {
if ( this.luacIsNumberIntegral ) {
int value = loadInt();
return new LInteger( value );
return LInteger.valueOf( value );
} else {
return longBitsToLuaNumber( loadInt64() );
}