for ( ; i < buflen ; ) { switch(ival = bytes[i++]) { case '0': if (nDigits > 0) { nTrailingZeroes++; } break; // switch case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (nTrailingZeroes > 0) { if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) { significand *= LONG_10_POWERS[nTrailingZeroes]; nTrailingZeroes = 0; } // else catch oversize below } if (nDigits++ < MAX_DECIMAL_DIGITS) { significand = significand*10L + (long)((int)ival-(int)'0'); break; // switch } else { state = SDIGIT; break states; } case '.': state = SOPTDECDIGIT_STRICT; break states; case 'e': case 'E': state = SOPTEXP_STRICT; break states; case '_': if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') { state = SERR_NOT_STRICT; break states; } break; // switch default: // only whitespace allowed after value for strict for ( --i; i < buflen && isWhitespace(bytes[i]); i++ ); state = i < buflen ? SERR_NOT_STRICT : SOPTCALC; break states; } // switch }
for ( ; i < buflen ; ) { switch(ival = bytes[i++]) { case '0': // ignore leading zeroes if (nDigits > 0) { // just save a count of zeroes for now; if no digit // ends up following them, they'll be applied to the // exponent rather than the significand (and our max // length for optimistic calc). nTrailingZeroes++; } break; // switch case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // ok, got a non-zero, have to own up to our horded zeroes if (nTrailingZeroes > 0) { if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) { significand *= LONG_10_POWERS[nTrailingZeroes]; nTrailingZeroes = 0; } // else catch oversize below } if (nDigits++ < MAX_DECIMAL_DIGITS) { significand = significand*10L + (long)((int)ival-(int)'0'); break; // switch } else { // oh, well, it was worth a try. go let // Double/FloatingDecimal handle it state = SDIGIT; break states; } case '.': state = SOPTDECDIGIT; break states; case 'e': case 'E': state = SOPTEXP; break states; case '_': // ignore break; // switch default: // end of parseable data, go to calc state = SOPTCALC; break states; } // switch }
Clone fragments detected by clone detection tool
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
                }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)4.4
Clones locationClones are in the same method
Number of node comparisons347
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements35
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)341.9
    Clone typeType 3
    Mapped Statements
    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;
    302
    state = SOPTDECDIGIT_STRICT;
    109
    state = SOPTDECDIGIT;
    Differences
    Expression1Expression2Difference
    SOPTDECDIGIT_STRICTSOPTDECDIGITVARIABLE_NAME_MISMATCH
    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;
    306
    state = SOPTEXP_STRICT;
    113
    state = SOPTEXP;
    Differences
    Expression1Expression2Difference
    SOPTEXP_STRICTSOPTEXPVARIABLE_NAME_MISMATCH
    113
    state = SOPTEXP;
    307
    break states;
    114
    break states;
    308
    case '_':
    115
    case '_':
    309
    if (i >= buflen || bytes[i] < '0' || bytes[i] > '9')
    309
    if (i >= buflen || bytes[i] < '0' || bytes[i] > '9')
    Preondition Violations
    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
                                                                                                                    
    310
    state = SERR_NOT_STRICT;
    310
    state = SERR_NOT_STRICT;
    Preondition Violations
    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
                                                          
    311
    break states;
    311
    break states;
    Preondition Violations
    Unmatched break states;
                                        
    312
    break;
    116
    break;
    313
    default:
    117
    default:
                                            
    118
    state = SOPTCALC;
    Preondition Violations
    Unmatched statement state=SOPTCALC; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    118
    state = SOPTCALC;
    314
    for (--i; i < buflen && isWhitespace(bytes[i]); i++)
    314
    for (--i; i < buflen && isWhitespace(bytes[i]); i++)
    Preondition Violations
    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
                                                                                                                    
    315
    ;
                
    316
    state = i < buflen ? SERR_NOT_STRICT : SOPTCALC;
    316
    state = i < buflen ? SERR_NOT_STRICT : SOPTCALC;
    Preondition Violations
    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
                                                                                                          
    317
    break states;
    119
    break states;
    Precondition Violations (7)
    Row Violation
    1Unmatched 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
    2Unmatched 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
    3Unmatched break states;
    4Unmatched statement state=SOPTCALC; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched 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
    6Unmatched 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
    7Clone fragment #1 returns variables i, ival, nDigits, nTrailingZeroes, significand , while Clone fragment #2 returns variables i, ival, nTrailingZeroes, nDigits, significand