for ( ; i < buflen ; ) { switch(ival = bytes[i++]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': chars[offset++] = (char)ival; lastValidOffset = offset; break; // switch case '.': state = SDECDIGIT_STRICT; break states; case 'e': case 'E': state = SEXP_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 : SCOMPLETE; break states; } // switch }
for ( ; i < buflen ; ) { switch(ival = bytes[i++]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': chars[offset++] = (char)ival; lastValidOffset = offset; break; // switch case 'e': case 'E': state = SEXP_STRICT; break states; case '_': if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') { state = SERR_NOT_STRICT; break states; } break; //switch default: for ( --i; i < buflen && isWhitespace(bytes[i]); i++) ; state = i < buflen ? SERR_NOT_STRICT : SCOMPLETE; 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: 32 Number of AST nodes: 29
1
for ( ; i < buflen ; ) {
1
for ( ; i < buflen ; ) {
2
                    switch(ival = bytes[i++]) {
2
                    switch(ival = bytes[i++]) {
3
                    case '0': case '1': case '2': case '3': case '4':
3
                    case '0': case '1': case '2': case '3': case '4':
4
                    case '5': case '6': case '7': case '8': case '9':
4
                    case '5': case '6': case '7': case '8': case '9':
5
                        chars[offset++] = (char)ival;
5
                        chars[offset++] = (char)ival;
6
                        lastValidOffset = offset;
6
                        lastValidOffset = offset;
7
                        break; // switch
7
                        break; // switch
8
                    case '.':
9
                        state = SDECDIGIT_STRICT;
10
                        break states;
11
                    case 'e':
8
                    case 'e':
12
                    case 'E':
9
                    case 'E':
13
                        state = SEXP_STRICT;
10
                        state = SEXP_STRICT;
14
                        break states;
11
                        break states;
15
                    case '_':
12
                    case '_':
16
                        if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') {
13
                        if (i >= buflen || bytes[i] < '0' || bytes[i] > '9') {
17
                            state = SERR_NOT_STRICT;
14
                            state = SERR_NOT_STRICT;
18
                            break states;
15
                            break states;
19
                        }
16
                        }
20
                        break; //switch
17
                        break; //switch
21
                    default:
18
                    default:
22
                        // only whitespace allowed after value for strict
23
                        for ( --i; i < buflen && isWhitespace(bytes[i]);  i++) ;
19
                        for ( --i; i < buflen && isWhitespace(bytes[i]);  i++) ;
24
                        state = i < buflen ? SERR_NOT_STRICT : SCOMPLETE; 
20
                        state = i < buflen ? SERR_NOT_STRICT : SCOMPLETE; 
25
                        break states;
21
                        break states;
26
                    } // switch
22
                    } // switch
27
                }
23
                }
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.3
Clones locationClones are in the same method
Number of node comparisons302
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements29
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)226.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    625
    for (; i < buflen; )
    681
    for (; i < buflen; )
    626
    switch (ival = bytes[i++])
    682
    switch (ival = bytes[i++])
    627
    case '0':
    683
    case '0':
    628
    case '1':
    684
    case '1':
    629
    case '2':
    685
    case '2':
    630
    case '3':
    686
    case '3':
    631
    case '4':
    687
    case '4':
    632
    case '5':
    688
    case '5':
    633
    case '6':
    689
    case '6':
    634
    case '7':
    690
    case '7':
    635
    case '8':
    691
    case '8':
    636
    case '9':
    692
    case '9':
    637
    chars[offset++] = (char)ival;
    693
    chars[offset++] = (char)ival;
    638
    lastValidOffset = offset;
    694
    lastValidOffset = offset;
    639
    break;
    695
    break;
    640
    case '.':
    640
    case '.':
    697
    case 'E':
    Differences
    Expression1Expression2Difference
    '.''E'LITERAL_VALUE_MISMATCH
    697
    case 'E':
    641
    state = SDECDIGIT_STRICT;
    641
    state = SDECDIGIT_STRICT;
    698
    state = SEXP_STRICT;
    Differences
    Expression1Expression2Difference
    SDECDIGIT_STRICTSEXP_STRICTVARIABLE_NAME_MISMATCH
    698
    state = SEXP_STRICT;
    642
    break states;
    699
    break states;
    643
    case 'e':
    696
    case 'e':
    644
    case 'E':
                                
    645
    state = SEXP_STRICT;
    645
    state = SEXP_STRICT;
    Preondition Violations
    Unmatched statement state=SEXP_STRICT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
    646
    break states;
    709
    break states;
    647
    case '_':
    700
    case '_':
    648
    if (i >= buflen || bytes[i] < '0' || bytes[i] > '9')
    701
    if (i >= buflen || bytes[i] < '0' || bytes[i] > '9')
    649
    state = SERR_NOT_STRICT;
    702
    state = SERR_NOT_STRICT;
    650
    break states;
    703
    break states;
    651
    break;
    704
    break;
    652
    default:
    705
    default:
    653
    for (--i; i < buflen && isWhitespace(bytes[i]); i++)
    706
    for (--i; i < buflen && isWhitespace(bytes[i]); i++)
    654
    ;
    707
    ;
    655
    state = i < buflen ? SERR_NOT_STRICT : SCOMPLETE;
    708
    state = i < buflen ? SERR_NOT_STRICT : SCOMPLETE;
    656
    break states;
    656
    break states;
    Preondition Violations
    Unmatched break states;
                                        
    Precondition Violations (3)
    Row Violation
    1Unmatched statement state=SEXP_STRICT; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched break states;
    3Clone fragment #1 returns variables i, ival, offset, chars, lastValidOffset , while Clone fragment #2 returns variables i, ival, offset, chars, lastValidOffset