while (true) { int i = len - 1; for (; i >= 0 && bytes[p + i] == 0; i--) bytes[p + i] = (byte)0xff; if (i < 0) return NeighborChar.WRAPPED; bytes[p + i] = (byte)((bytes[p + i] & 0xff) - 1); int cl = StringSupport.preciseLength(enc, bytes, p, p + len); if (cl > 0) { if (cl == len) { return NeighborChar.FOUND; } else { for (int j = p + cl; j < p + len - cl; j++) bytes[j] = 0; } } if (cl == -1 && i < len - 1) { int len2 = len - 1; for (; len2 > 0; len2--) { if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1) break; } for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++) bytes[j] = 0; } }
while (true) { int i = len - 1; for (; i >= 0 && bytes[p + i] == (byte)0xff; i--) bytes[p + i] = 0; if (i < 0) return NeighborChar.WRAPPED; bytes[p + i] = (byte)((bytes[p + i] & 0xff) + 1); int cl = StringSupport.preciseLength(enc, bytes, p, p + len); if (cl > 0) { if (cl == len) { return NeighborChar.FOUND; } else { for (int j = p + cl; j < p + len - cl; j++) bytes[j] = (byte)0xff; } } if (cl == -1 && i < len - 1) { int len2 = len - 1; for (; len2 > 0; len2--) { if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1) break; } for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++) bytes[j] = (byte)0xff; } }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyString.java File path: /jruby-1.4.0/src/org/jruby/RubyString.java
Method name: NeighborChar predChar(Encoding, byte[], int, int) Method name: NeighborChar succChar(Encoding, byte[], int, int)
Number of AST nodes: 20 Number of AST nodes: 20
1
while (true) {
1
while (true) {
2
            int i = len - 1;
2
            int i = len - 1;
3
            for (; i >= 0 && bytes[p + i] == 0; i--) bytes[p + i] = (byte)0xff;
3
            for (; i >= 0 && bytes[p + i] == (byte)0xff; i--) bytes[p + i] = 0;
4
            if (i < 0) return NeighborChar.WRAPPED;
4
            if (i < 0) return NeighborChar.WRAPPED;
5
            bytes[p + i] = (byte)((bytes[p + i] & 0xff) - 1);
5
            bytes[p + i] = (byte)((bytes[p + i] & 0xff) + 1);
6
            int cl = StringSupport.preciseLength(enc, bytes, p, p + len);
6
            int cl = StringSupport.preciseLength(enc, bytes, p, p + len);
7
            if (cl > 0) {
7
            if (cl > 0) {
8
                if (cl == len) {
8
                if (cl == len) {
9
                    return NeighborChar.FOUND;
9
                    return NeighborChar.FOUND;
10
                } else {
10
                } else {
11
                    for (int j = p + cl; j < p + len - cl; j++) bytes[j] = 0;
11
                    for (int j = p + cl; j < p + len - cl; j++) bytes[j] = (byte)0xff;
12
                }
12
                }
13
            }
13
            }
14
            if (cl == -1 && i < len - 1) {
14
            if (cl == -1 && i < len - 1) {
15
                int len2 = len - 1;
15
                int len2 = len - 1;
16
                for (; len2 > 0; len2--) {
16
                for (; len2 > 0; len2--) {
17
                    if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1) break;
17
                    if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1) break;
18
                }
18
                }
19
                for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++) bytes[j] = 0;
19
                for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++) bytes[j] = (byte)0xff;
20
            }
20
            }
21
        }
21
        }
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)9.7
Clones locationClones are declared in the same class
Number of node comparisons66
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)11.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    while (true)
    1
    while (true)
    2
    int i = len - 1;
    2
    int i = len - 1;
                                                                                                      
    3
    for (; i >= 0 && bytes[p + i] == (byte)0xff; i--)
    Preondition Violations
    Unmatched statement for(i >= 0 && bytes[p + i] == (byte)0xff; i--) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    for (; i >= 0 && bytes[p + i] == (byte)0xff; i--)
                                        
    4
    bytes[p + i] = 0;
    Preondition Violations
    Unmatched statement bytes[p + i]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    bytes[p + i] = 0;
    3
    for (; i >= 0 && bytes[p + i] == 0; i--)
    3
    for (; i >= 0 && bytes[p + i] == 0; i--)
    Preondition Violations
    Unmatched statement for(i >= 0 && bytes[p + i] == 0; i--) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    4
    bytes[p + i] = (byte)0xff;
    4
    bytes[p + i] = (byte)0xff;
    Preondition Violations
    Unmatched statement bytes[p + i]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
    5
    if (i < 0)
    5
    if (i < 0)
    6
    return NeighborChar.WRAPPED;
    6
    return NeighborChar.WRAPPED;
                                                                                                        
    7
    bytes[p + i] = (byte)((bytes[p + i] & 0xff) + 1);
    Preondition Violations
    Unmatched statement bytes[p + i]=(byte)((bytes[p + i] & 0xff) + 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    bytes[p + i] = (byte)((bytes[p + i] & 0xff) + 1);
    7
    bytes[p + i] = (byte)((bytes[p + i] & 0xff) - 1);
    7
    bytes[p + i] = (byte)((bytes[p + i] & 0xff) - 1);
    Preondition Violations
    Unmatched statement bytes[p + i]=(byte)((bytes[p + i] & 0xff) - 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                        
    8
    int cl = StringSupport.preciseLength(enc, bytes, p, p + len);
    8
    int cl = StringSupport.preciseLength(enc, bytes, p, p + len);
    9
    if (cl > 0)
    9
    if (cl > 0)
    10
    if (cl == len)
    10
    if (cl == len)
    11
    return NeighborChar.FOUND;
    11
    return NeighborChar.FOUND;
    else
    else
    12
    for (int j = p + cl; j < p + len - cl; j++)
    12
    for (int j = p + cl; j < p + len - cl; j++)
                                                    
    13
    bytes[j] = (byte)0xff;
    Preondition Violations
    Unmatched statement bytes[j]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    bytes[j] = (byte)0xff;
    13
    bytes[j] = 0;
    13
    bytes[j] = 0;
    Preondition Violations
    Unmatched statement bytes[j]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
    14
    if (cl == -1 && i < len - 1)
    14
    if (cl == -1 && i < len - 1)
    15
    int len2 = len - 1;
    15
    int len2 = len - 1;
    16
    for (; len2 > 0; len2--)
    16
    for (; len2 > 0; len2--)
    17
    if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1)
    17
    if (StringSupport.preciseLength(enc, bytes, p, p + len2) != -1)
    18
    break;
    18
    break;
    19
    for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++)
    19
    for (int j = p + len2 + 1; j < p + len - (len2 + 1); j++)
                                                    
    20
    bytes[j] = (byte)0xff;
    Preondition Violations
    Unmatched statement bytes[j]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20
    bytes[j] = (byte)0xff;
    20
    bytes[j] = 0;
    20
    bytes[j] = 0;
    Preondition Violations
    Unmatched statement bytes[j]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                  
    Precondition Violations (11)
    Row Violation
    1Unmatched statement for(i >= 0 && bytes[p + i] == (byte)0xff; i--) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement bytes[p + i]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement for(i >= 0 && bytes[p + i] == 0; i--) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement bytes[p + i]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement bytes[p + i]=(byte)((bytes[p + i] & 0xff) + 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement bytes[p + i]=(byte)((bytes[p + i] & 0xff) - 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement bytes[j]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement bytes[j]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement bytes[j]=(byte)0xff; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement bytes[j]=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Clone fragment #1 returns variables i, j, j , while Clone fragment #2 returns variables i, j, j