Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1266b08

Browse files
committed
Replacing computational expensive pow call with result of accumulated multiplication.
1 parentfae13e5 commit1266b08

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎api/Stream.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include"Common.h"
2626
#include"Stream.h"
27-
#include<math.h>
2827

2928
#definePARSE_TIMEOUT1000// default number of milli-seconds to wait
3029

@@ -165,7 +164,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
165164
bool isFraction =false;
166165
double value =0.0;
167166
int c;
168-
unsignedint digits_post_comma =0;
167+
double fraction =1.0;
169168

170169
c =peekNextDigit(lookahead,true);
171170
// ignore non numeric leading characters
@@ -182,7 +181,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
182181
elseif(c >='0' && c <='9') {// is c a digit?
183182
value = value *10 + c -'0';
184183
if(isFraction)
185-
digits_post_comma++;
184+
fraction *=0.1;
186185
}
187186
read();// consume the character we got with peek
188187
c =timedPeek();
@@ -193,7 +192,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
193192
value = -value;
194193

195194
if(isFraction)
196-
value/=pow(10, digits_post_comma);
195+
value*= fraction;
197196

198197
return value;
199198
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp