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_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': 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 }
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: 39 Number of AST nodes: 34
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
                        if (nDigits > 0) {
4
                        if (nDigits > 0) {
5
                            nTrailingZeroes++;
5
                            nTrailingZeroes++;
6
                        } else {
6
                        } else {
7
                            exponent--;
7
                            exponent--;
8
                        }
8
                        }
9
                        break; // switch
9
                        break; // switch
10
                    case '1': case '2': case '3': case '4':
10
                    case '1': case '2': case '3': case '4':
11
                    case '5': case '6': case '7': case '8': case '9':
11
                    case '5': case '6': case '7': case '8': case '9':
12
                        if (nTrailingZeroes > 0) {
12
                        if (nTrailingZeroes > 0) {
13
                            if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {
13
                            if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS) {
14
                                significand *= LONG_10_POWERS[nTrailingZeroes];
14
                                significand *= LONG_10_POWERS[nTrailingZeroes];
15
                                nTrailingZeroes = 0;
15
                                nTrailingZeroes = 0;
16
                            } // else catch oversize below
16
                            } // else catch oversize below
17
                        }
17
                        }
18
                        if (nDigits++ < MAX_DECIMAL_DIGITS) {
18
                        if (nDigits++ < MAX_DECIMAL_DIGITS) {
19
                            significand = significand*10L + (long)((int)ival-(int)'0');
19
                            significand = significand*10L + (long)((int)ival-(int)'0');
20
                            break; // switch
20
                            break; // switch
21
                        } else {
21
                        } else {
22
                            state = SDIGIT;
22
                            state = SDIGIT;
23
                            break states;
23
                            break states;
24
                        }
24
                        }
25
                    case 'e':
25
                    case 'e':
26
                    case 'E':
26
                    case 'E':
27
                        state = SOPTEXP_STRICT;
27
                        state = SOPTEXP;
28
                        break states;
28
                        break states;
29
                    case '_':
29
                    case '_':
30
                        if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') {
30
                        
31
                            state = SERR_NOT_STRICT;
32
                            break states;
33
                        }
34
                        break; // switch
35
                    default:
36
                        // only whitespace allowed after value for strict
37
                        for ( --i; i < buflen && isWhitespace(bytes[i]); i++);
38
                        state = i < buflen ? SERR_NOT_STRICT :
31
// ignore
32
                        break; // switch
33
                    default:
34
                        // end of parseable data, go to calc
39
 SOPTCALC; 
35
                        state = SOPTCALC;
40
                        break states;
36
                        break states;
41
                    } // switch
37
                    } // switch
42
                }
38
                }
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.2
Clones locationClones are in the same method
Number of node comparisons288
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements33
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)56.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    352
    for (; i < buflen; )
    154
    for (; i < buflen; )
    353
    switch (ival = bytes[i++])
    155
    switch (ival = bytes[i++])
    354
    case '0':
    156
    case '0':
    355
    if (nDigits > 0)
    157
    if (nDigits > 0)
    356
    nTrailingZeroes++;
    158
    nTrailingZeroes++;
    else
    else
    357
    exponent--;
    159
    exponent--;
    358
    break;
    160
    break;
    359
    case '1':
    161
    case '1':
    360
    case '2':
    162
    case '2':
    361
    case '3':
    163
    case '3':
    362
    case '4':
    164
    case '4':
    363
    case '5':
    165
    case '5':
    364
    case '6':
    166
    case '6':
    365
    case '7':
    167
    case '7':
    366
    case '8':
    168
    case '8':
    367
    case '9':
    169
    case '9':
    368
    if (nTrailingZeroes > 0)
    170
    if (nTrailingZeroes > 0)
    369
    if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS)
    171
    if ((nDigits += nTrailingZeroes) < MAX_DECIMAL_DIGITS)
    370
    significand *= LONG_10_POWERS[nTrailingZeroes];
    172
    significand *= LONG_10_POWERS[nTrailingZeroes];
    371
    nTrailingZeroes = 0;
    173
    nTrailingZeroes = 0;
    372
    if (nDigits++ < MAX_DECIMAL_DIGITS)
    174
    if (nDigits++ < MAX_DECIMAL_DIGITS)
    373
    significand = significand * 10L + (long)((int)ival - (int)'0');
    175
    significand = significand * 10L + (long)((int)ival - (int)'0');
    374
    break;
    176
    break;
    else
    else
    375
    state = SDIGIT;
    177
    state = SDIGIT;
    376
    break states;
    178
    break states;
    377
    case 'e':
    179
    case 'e':
    378
    case 'E':
    180
    case 'E':
    379
    state = SOPTEXP_STRICT;
    379
    state = SOPTEXP_STRICT;
    181
    state = SOPTEXP;
    Differences
    Expression1Expression2Difference
    SOPTEXP_STRICTSOPTEXPVARIABLE_NAME_MISMATCH
    181
    state = SOPTEXP;
    380
    break states;
    182
    break states;
    381
    case '_':
    183
    case '_':
    382
    if (i >= buflen || bytes[i] < '0' || bytes[i] > '9')
    382
    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
                                                                                                                    
    383
    state = SERR_NOT_STRICT;
    383
    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
                                                          
    384
    break states;
    384
    break states;
    Preondition Violations
    Unmatched break states;
                                        
    385
    break;
    184
    break;
    386
    default:
    185
    default:
                                            
    186
    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
    186
    state = SOPTCALC;
    387
    for (--i; i < buflen && isWhitespace(bytes[i]); i++)
    387
    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
                                                                                                                    
    388
    ;
                
    389
    state = i < buflen ? SERR_NOT_STRICT : SOPTCALC;
    389
    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
                                                                                                          
    390
    break states;
    187
    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, exponent , while Clone fragment #2 returns variables i, ival, nDigits, nTrailingZeroes, significand, exponent