File path: /jruby-1.4.0/src/org/jruby/util/Convert.java | File path: /jruby-1.4.0/src/org/jruby/util/Convert.java | |||
Method name: double byteArrayToDouble(byte[], int, int, boolean)
|
Method name: double byteArrayToDouble(byte[], int, int, boolean)
|
|||
Number of AST nodes: 41 | Number of AST nodes: 36 | |||
1 | for ( ; i < buflen ; ) {↵ | 1 | for ( ; i < buflen ; ) {↵ | |
2 | switch(ival = bytes[i++]) {↵ | 2 | switch(ival = bytes[i++]) {↵ | |
3 | case '0':↵ | 3 | case '0':↵ | |
4 | // ignore leading zeroes↵ | |||
4 | if (nDigits > 0) {↵ | 5 | if (nDigits > 0) {↵ | |
6 | // just save a count of zeroes for now; if no digit↵ | |||
7 | // ends up following them, they'll be applied to the↵ | |||
8 | // exponent rather than the significand (and our max↵ | |||
9 | // length for optimistic calc).↵ | |||
5 | nTrailingZeroes++;↵ | 10 | nTrailingZeroes++;↵ | |
6 | }↵ | 11 | }↵ | |
7 | break; // switch↵ | 12 | break; // switch↵ | |
8 | case '1': case '2': case '3': case '4':↵ | 13 | case '1': case '2': case '3': case '4':↵ | |
9 | case '5': case '6': case '7': case '8': case '9':↵ | 14 | case '5': case '6': case '7': case '8': case '9':↵ | |
15 | // ok, got a non-zero, have to own up to our horded zeroes↵ | |||
10 | if (nTrailingZeroes > 0) {↵ | 16 | if (nTrailingZeroes > 0) {↵ | |
11 | if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {↵ | 17 | if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {↵ | |
12 | significand *= LONG_10_POWERS[nTrailingZeroes];↵ | 18 | significand *= LONG_10_POWERS[nTrailingZeroes];↵ | |
13 | nTrailingZeroes = 0;↵ | 19 | nTrailingZeroes = 0;↵ | |
14 | } // else catch oversize below↵ | 20 | } // else catch oversize below↵ | |
15 | }↵ | 21 | }↵ | |
16 | if (nDigits++ < MAX_DECIMAL_DIGITS) {↵ | 22 | if (nDigits++ < MAX_DECIMAL_DIGITS) {↵ | |
17 | significand = significand*10L + (long)((int)ival-(int)'0');↵ | 23 | significand = significand*10L + (long)((int)ival-(int)'0');↵ | |
18 | break; // switch↵ | 24 | break; // switch↵ | |
19 | } else {↵ | 25 | } else {↵ | |
20 | state = SDIGIT;↵ | 26 | ↵ | |
21 | break states;↵ | |||
22 | }↵ | |||
23 | case '.':↵ | |||
24 | state = SOPTDECDIGIT_STRICT;↵ | |||
27 | // oh, well, it was worth a try. go let↵ | |||
28 | // Double/FloatingDecimal handle it ↵ | |||
29 | state = SDIGIT;↵ | |||
25 | break states;↵ | 30 | break states;↵ | |
26 | case 'e':↵ | 31 | }↵ | |
27 | case 'E':↵ | 32 | case '.':↵ | |
28 | state = SOPTEXP_STRICT;↵ | 33 | state = SOPTDECDIGIT;↵ | |
29 | break states;↵ | 34 | break states;↵ | |
30 | case '_':↵ | 35 | case 'e':↵ | |
31 | if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') {↵ | 36 | ↵ | |
32 | ↵ | 37 | case 'E':↵ | |
33 | state = SERR_NOT_STRICT;↵ | 38 | state = S↵ | |
34 | ↵ | 39 | OPTEXP;↵ | |
35 | break states;↵ | 40 | break states;↵ | |
36 | }↵ | 41 | case '_':↵ | |
42 | // ignore↵ | |||
37 | break; // switch↵ | 43 | break; // switch↵ | |
38 | default:↵ | 44 | default:↵ | |
39 | // only whitespace allowed after value for strict↵ | 45 | // ↵ | |
40 | for ( --i; i < buflen && isWhitespace(bytes[i]); i++ );↵ | |||
41 | state = i < buflen ? SERR_NOT_STRICT : SOPTCALC; ↵ | 46 | end of parseable data, go to calc↵ | |
47 | state = SOPTCALC;↵ | |||
48 | break states;↵ | |||
42 | break states;↵ | 49 | ↵ | |
43 | } // switch↵ | 50 | } // switch↵ | |
44 | } | 51 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 4.4 |
Clones location | Clones are in the same method |
Number of node comparisons | 347 |
Number of mapped statements | 35 |
Number of unmapped statements in the first code fragment | 6 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 341.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
277 | for (; i < buflen; ) | 84 | for (; i < buflen; ) | |||||||||||
278 | switch (ival = bytes[i++]) | 85 | switch (ival = bytes[i++]) | |||||||||||
279 | case '0': | 86 | case '0': | |||||||||||
280 | if (nDigits > 0) | 87 | if (nDigits > 0) | |||||||||||
281 | nTrailingZeroes++; | 88 | nTrailingZeroes++; | |||||||||||
282 | break; | 89 | break; | |||||||||||
283 | case '1': | 90 | case '1': | |||||||||||
284 | case '2': | 91 | case '2': | |||||||||||
285 | case '3': | 92 | case '3': | |||||||||||
286 | case '4': | 93 | case '4': | |||||||||||
287 | case '5': | 94 | case '5': | |||||||||||
288 | case '6': | 95 | case '6': | |||||||||||
289 | case '7': | 96 | case '7': | |||||||||||
290 | case '8': | 97 | case '8': | |||||||||||
291 | case '9': | 98 | case '9': | |||||||||||
292 | if (nTrailingZeroes > 0) | 99 | if (nTrailingZeroes > 0) | |||||||||||
293 | if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) | 100 | if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) | |||||||||||
294 | significand *= LONG_10_POWERS[nTrailingZeroes]; | 101 | significand *= LONG_10_POWERS[nTrailingZeroes]; | |||||||||||
295 | nTrailingZeroes = 0; | 102 | nTrailingZeroes = 0; | |||||||||||
296 | if (nDigits++ < MAX_DECIMAL_DIGITS) | 103 | if (nDigits++ < MAX_DECIMAL_DIGITS) | |||||||||||
297 | significand = significand * 10L + (long)((int)ival - (int)'0'); | 104 | significand = significand * 10L + (long)((int)ival - (int)'0'); | |||||||||||
298 | break; | 105 | break; | |||||||||||
else | else | |||||||||||||
299 | state = SDIGIT; | 106 | state = SDIGIT; | |||||||||||
300 | break states; | 107 | break states; | |||||||||||
301 | case '.': | 108 | case '.': | |||||||||||
302 | state = SOPTDECDIGIT_STRICT; |
| 109 | state = SOPTDECDIGIT; | ||||||||||
303 | break states; | 110 | break states; | |||||||||||
304 | case 'e': | 111 | case 'e': | |||||||||||
305 | case 'E': | 112 | case 'E': | |||||||||||
306 | state = SOPTEXP_STRICT; |
| 113 | state = SOPTEXP; | ||||||||||
307 | break states; | 114 | break states; | |||||||||||
308 | case '_': | 115 | case '_': | |||||||||||
309 | if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') |
| | |||||||||||
310 | state = SERR_NOT_STRICT; |
| | |||||||||||
311 | break states; |
| | |||||||||||
312 | break; | 116 | break; | |||||||||||
313 | default: | 117 | default: | |||||||||||
|
| 118 | state = SOPTCALC; | |||||||||||
314 | for (--i; i < buflen && isWhitespace(bytes[i]); i++) |
| | |||||||||||
315 | ; | | ||||||||||||
316 | state = i < buflen ? SERR_NOT_STRICT : SOPTCALC; |
| | |||||||||||
317 | break states; | 119 | break states; |
Row | Violation |
---|---|
1 | Unmatched statement if(i >= buflen || bytes[i] < '0' || bytes[i] > '9') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement state=SERR_NOT_STRICT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched break states; |
4 | Unmatched statement state=SOPTCALC; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement for(--i; i < buflen && isWhitespace(bytes[i]); i++) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement state=i < buflen ? SERR_NOT_STRICT : SOPTCALC; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Clone fragment #1 returns variables i, ival, nDigits, nTrailingZeroes, significand , while Clone fragment #2 returns variables i, ival, nTrailingZeroes, nDigits, significand |