for ( ; i < buflen ; ) { switch(ival = bytes[i++]) { case '0': if (nDigits > 0) { nTrailingZeroes++; } else { exponent--; } 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 'e': case 'E': state = SOPTEXP; break states; case '_': // ignore break; // switch default: // end of parseable data, go to calc state = SOPTCALC; break states; } // switch }
switch(ival = bytes[i++]) { case '0': if (nDigits > 0) { nTrailingZeroes++; } else { exponent--; } 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; } default: // no dec digits after '.', error for strict state = SERR_NOT_STRICT; break states; }
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: 34 Number of AST nodes: 27
1
for ( ; i < buflen ; ) {
2
                    switch(ival = bytes[i++]) {
1
switch(ival = bytes[i++]) {
3
                    case '0':
2
                    case '0':
4
                        if (nDigits > 0) {
3
                        if (nDigits > 0) {
5
                            nTrailingZeroes++;
4
                            nTrailingZeroes++;
6
                        } else {
5
                        } else {
7
                            exponent--;
6
                            exponent--;
8
                        }
7
                        }
9
                        break; // switch
8
                        break; // switch
10
                    case '1': case '2': case '3': case '4':
9
                    case '1': case '2': case '3': case '4':
11
                    case '5': case '6': case '7': case '8': case '9':
10
                    case '5': case '6': case '7': case '8': case '9':
12
                        if (nTrailingZeroes > 0) {
11
                        if (nTrailingZeroes > 0) {
13
                            if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {
12
                            if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {
14
                                significand *= LONG_10_POWERS[nTrailingZeroes];
13
                                significand *= LONG_10_POWERS[nTrailingZeroes];
15
                                nTrailingZeroes = 0;
14
                                nTrailingZeroes = 0;
16
                            } // else catch oversize below
15
                            } // else catch oversize below
17
                        }
16
                        }
18
                        if (nDigits++ < MAX_DECIMAL_DIGITS) {
17
                        if (nDigits++ < MAX_DECIMAL_DIGITS) {
19
                            significand = significand*10L + (long)((int)ival-(int)'0');
18
                            significand = significand*10L + (long)((int)ival-(int)'0');
20
                            break; // switch
19
                            break; // switch
21
                        } else {
20
                        } else {
22
                            state = SDIGIT;
21
                            state = SDIGIT;
23
                            break states;
22
                            break states;
24
                        }
23
                        }
25
                    case 'e':
24
                    
26
                    case 'E':
27
                        state = SOPTEXP;
28
                        break states;
29
                    case '_':
30
                        // ignore
31
                        break; // switch
32
                    default:
33
                        // end of parseable data, go to calc
25
default:
26
                        // no dec digits after '.', error for strict
34
                        state = SOPTCALC;
27
                        state = SERR_NOT_STRICT;
35
                        break states;
28
                        break states;
36
                    } // switch
29
                    
30
    
37
                }
31
                    }
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)2.3
Clones locationClones are in the same method
Number of node comparisons191
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements27
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)50.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    155
    switch (ival = bytes[i++])
    323
    switch (ival = bytes[i++])
    156
    case '0':
    324
    case '0':
    157
    if (nDigits > 0)
    325
    if (nDigits > 0)
    158
    nTrailingZeroes++;
    326
    nTrailingZeroes++;
    else
    else
    159
    exponent--;
    327
    exponent--;
    160
    break;
    328
    break;
    161
    case '1':
    329
    case '1':
    162
    case '2':
    330
    case '2':
    163
    case '3':
    331
    case '3':
    164
    case '4':
    332
    case '4':
    165
    case '5':
    333
    case '5':
    166
    case '6':
    334
    case '6':
    167
    case '7':
    335
    case '7':
    168
    case '8':
    336
    case '8':
    169
    case '9':
    337
    case '9':
    170
    if (nTrailingZeroes > 0)
    338
    if (nTrailingZeroes > 0)
    171
    if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS)
    339
    if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS)
    172
    significand *= LONG_10_POWERS[nTrailingZeroes];
    340
    significand *= LONG_10_POWERS[nTrailingZeroes];
    173
    nTrailingZeroes = 0;
    341
    nTrailingZeroes = 0;
    174
    if (nDigits++ < MAX_DECIMAL_DIGITS)
    342
    if (nDigits++ < MAX_DECIMAL_DIGITS)
    175
    significand = significand * 10L + (long)((int)ival - (int)'0');
    343
    significand = significand * 10L + (long)((int)ival - (int)'0');
    176
    break;
    344
    break;
    else
    else
    177
    state = SDIGIT;
    345
    state = SDIGIT;
    178
    break states;
    346
    break states;
    179
    case 'e':
                                
    180
    case 'E':
                                
    181
    state = SOPTEXP;
    181
    state = SOPTEXP;
    Preondition Violations
    Unmatched statement state=SOPTEXP; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                          
    182
    break states;
    182
    break states;
    Preondition Violations
    Unmatched break states;
                                        
    183
    case '_':
                                
    184
    break;
    184
    break;
    Preondition Violations
    Unmatched break;
                          
    185
    default:
    347
    default:
    186
    state = SOPTCALC;
    186
    state = SOPTCALC;
    348
    state = SERR_NOT_STRICT;
    Differences
    Expression1Expression2Difference
    SOPTCALCSERR_NOT_STRICTVARIABLE_NAME_MISMATCH
    348
    state = SERR_NOT_STRICT;
    187
    break states;
    349
    break states;
    Precondition Violations (4)
    Row Violation
    1Unmatched statement state=SOPTEXP; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched break states;
    3Unmatched break;
    4Clone fragment #1 returns variables i, ival, nDigits, nTrailingZeroes, significand, exponent , while Clone fragment #2 returns variables i, ival, nDigits, nTrailingZeroes, significand, exponent