@@ -89,6 +89,7 @@ SmallDecimalParsingResult parseJsonNumberImpl()(scope const(char)[] str)
89
89
return result;
90
90
}
91
91
92
+ version (mir_test)
92
93
unittest
93
94
{
94
95
import mir.test;
@@ -99,6 +100,19 @@ unittest
99
100
res.coefficient.should == 1234567890 ;
100
101
}
101
102
103
+ version (mir_test)
104
+ unittest
105
+ {
106
+ import mir.test;
107
+ auto res = " -12345.67890e-10" .parseJsonNumberImpl;
108
+ res.key.should == DecimalExponentKey.e;
109
+ res.sign.should == true ;
110
+ res.exponent.should == - 15 ;
111
+ res.coefficient.should == 1234567890 ;
112
+ }
113
+
114
+
115
+ version (mir_test)
102
116
unittest
103
117
{
104
118
import mir.test;
@@ -156,6 +170,7 @@ template decimalFromStringImpl(alias mullAdd, W = size_t)
156
170
}
157
171
}
158
172
173
+ W multiplier = 10 ;
159
174
W d = str[0 ] - C(' 0' );
160
175
str = str[1 .. $];
161
176
@@ -205,8 +220,26 @@ template decimalFromStringImpl(alias mullAdd, W = size_t)
205
220
206
221
if (d < 10 )
207
222
{
223
+ multiplier = 10 ;
224
+ static if (is (C == char ) && is (W == ulong ))
225
+ if (! __ctfe)
226
+ if (str.length >= 8 && isMadeOfEightDigits(str[0 .. 8 ]))
227
+ {
228
+ multiplier = 1000000000UL ;
229
+ d *= 100000000 ;
230
+ d += parseEightDigits(str[0 .. 8 ]);
231
+ str = str[8 .. $];
232
+ if (str.length >= 8 && isMadeOfEightDigits(str[0 .. 8 ]))
233
+ {
234
+ multiplier = 1000000000UL * 100000000 ;
235
+ d *= 100000000 ;
236
+ d += parseEightDigits(str[0 .. 8 ]);
237
+ str = str[8 .. $];
238
+ }
239
+ }
240
+
208
241
F0 :
209
- if (_expect(mullAdd(10u , cast ( uint ) d), false ))
242
+ if (_expect(mullAdd(multiplier, d), false ))
210
243
return false ;
211
244
goto S;
212
245
}
@@ -239,7 +272,7 @@ template decimalFromStringImpl(alias mullAdd, W = size_t)
239
272
}
240
273
241
274
IF :
242
- W multiplier = 10 ;
275
+ multiplier = 10 ;
243
276
static if (is (C == char ) && is (W == ulong ))
244
277
if (! __ctfe)
245
278
{
@@ -305,8 +338,6 @@ template decimalFromStringImpl(alias mullAdd, W = size_t)
305
338
FIL :
306
339
if (_expect(mullAdd(multiplier, d), false ))
307
340
return false ;
308
- import mir.stdio;
309
- // debug dump("str = ", str);
310
341
if (str.length == 0 )
311
342
return true ;
312
343
d = str[0 ] - C(' 0' );
@@ -348,13 +379,9 @@ template decimalFromStringImpl(alias mullAdd, W = size_t)
348
379
long exponentPlus;
349
380
if (parse(str, exponentPlus) && str.length == 0 )
350
381
{
351
- import mir.stdio;
352
- // debug dump("exponentPlus ", exponentPlus);
353
- // debug dump("exponent ", exponent);
354
382
import mir.checkedint: adds;
355
383
bool overflow;
356
384
exponent = exponent.adds(exponentPlus, overflow);
357
- // debug dump("overflow ", overflow);
358
385
return ! overflow;
359
386
}
360
387
}
0 commit comments