mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
make NumberLong floatApprox casts more incremental - some compilers may have been optimizing them out
This commit is contained in:
parent
f8cb1e292c
commit
7d1b346700
@ -551,8 +551,9 @@ namespace mongo {
|
||||
void makeLongObj( long long n, JSObject * o ) {
|
||||
boost::uint64_t val = (boost::uint64_t)n;
|
||||
CHECKNEWOBJECT(o,_context,"NumberLong1");
|
||||
setProperty( o , "floatApprox" , toval( (double)(boost::int64_t)( val ) ) );
|
||||
if ( (boost::int64_t)val != (boost::int64_t)(double)(boost::int64_t)( val ) ) {
|
||||
double floatApprox = (double)(boost::int64_t)val;
|
||||
setProperty( o , "floatApprox" , toval( floatApprox ) );
|
||||
if ( (boost::int64_t)val != (boost::int64_t)floatApprox ) {
|
||||
// using 2 doubles here instead of a single double because certain double
|
||||
// bit patterns represent undefined values and sm might trash them
|
||||
setProperty( o , "top" , toval( (double)(boost::uint32_t)( val >> 32 ) ) );
|
||||
|
@ -217,14 +217,15 @@ namespace mongo {
|
||||
Local<v8::Object> sub = readOnly ? readOnlyObjects->NewInstance() : internalFieldObjects->NewInstance();
|
||||
unsigned long long val = f.numberLong();
|
||||
v8::Function* numberLong = getNamedCons( "NumberLong" );
|
||||
if ( (long long)val == (long long)(double)(long long)(val) ) {
|
||||
double floatApprox = (double)(long long)val;
|
||||
if ( (long long)val == (long long)floatApprox ) {
|
||||
v8::Handle<v8::Value> argv[1];
|
||||
argv[0] = v8::Number::New( (double)(long long)( val ) );
|
||||
argv[0] = v8::Number::New( floatApprox );
|
||||
o->Set( v8::String::New( f.fieldName() ), numberLong->NewInstance( 1, argv ) );
|
||||
}
|
||||
else {
|
||||
v8::Handle<v8::Value> argv[3];
|
||||
argv[0] = v8::Number::New( (double)(long long)(val) );
|
||||
argv[0] = v8::Number::New( floatApprox );
|
||||
argv[1] = v8::Integer::New( val >> 32 );
|
||||
argv[2] = v8::Integer::New( (unsigned long)(val & 0x00000000ffffffff) );
|
||||
o->Set( v8::String::New( f.fieldName() ), numberLong->NewInstance(3, argv) );
|
||||
|
Loading…
Reference in New Issue
Block a user