Browse Source

# fast_atoreal_move: avoid floating-point casts. Compilers have trouble optimizing this.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1144 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 13 years ago
parent
commit
16b3d19f7f
1 changed files with 3 additions and 3 deletions
  1. 3 3
      code/fast_atof.h

+ 3 - 3
code/fast_atof.h

@@ -257,7 +257,7 @@ inline const char* fast_atoreal_move( const char* c, Real& out)
 	if (*c == 'e' || *c == 'E')	{
 	if (*c == 'e' || *c == 'E')	{
 
 
 		++c;
 		++c;
-		bool einv = (*c=='-');
+		const bool einv = (*c=='-');
 		if (einv || *c=='+') {
 		if (einv || *c=='+') {
 			++c;
 			++c;
 		}
 		}
@@ -267,13 +267,13 @@ inline const char* fast_atoreal_move( const char* c, Real& out)
 		// bad considering how frequently fast_atoreal_move<float> is called in Assimp.
 		// bad considering how frequently fast_atoreal_move<float> is called in Assimp.
 		Real exp = static_cast<Real>( strtoul10_64(c, &c) );
 		Real exp = static_cast<Real>( strtoul10_64(c, &c) );
 		if (einv) {
 		if (einv) {
-			exp *= static_cast<Real>(-1.0f);
+			exp = -exp;
 		}
 		}
 		f *= pow(static_cast<Real>(10.0f), exp);
 		f *= pow(static_cast<Real>(10.0f), exp);
 	}
 	}
 
 
 	if (inv) {
 	if (inv) {
-		f *= static_cast<Real>(-1.0f);
+		f = -f;
 	}
 	}
 	out = f;
 	out = f;
 	return c;
 	return c;