for (int i = 1; i <= alphaSize; i++) { int j = 0; int k = i; for (int parent_k; (parent_k = parent[k]) >= 0;) { k = parent_k; j++; } len[i - 1] = (char) j; if (j > maxLen) { tooLong = true; } }
for (int i = 1; i <= alphaSize; i++) { int j = 0; int k = i; for (int parent_k; (parent_k = parent[k]) >= 0;) { k = parent_k; j++; } len[i - 1] = (byte) j; if (j > maxLen) { tooLong = true; } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/bzip2/CBZip2OutputStream.java File path: /apache-ant-1.7.0/src/org/apache/tools/bzip2/CBZip2OutputStream.java
Method name: void hbMakeCodeLengths(char[], int[], int, int) Method name: void hbMakeCodeLengths(byte[], int[], Data, int, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
for (int i = 1; i <= alphaSize; i++) {
1
for (int i = 1; i <= alphaSize; i++) {
2
                int j = 0;
2
                int j = 0;
3
                int k = i;
3
                int k = i;
4
                for (int parent_k; (parent_k = parent[k]) >= 0;) {
4
                for (int parent_k; (parent_k = parent[k]) >= 0;) {
5
                    k = parent_k;
5
                    k = parent_k;
6
                    j++;
6
                    j++;
7
                }
7
                }
8
                len[i - 1] = (char) j;
8
                len[i - 1] = (byte) j;
9
                if (j > maxLen) {
9
                if (j > maxLen) {
10
                    tooLong = true;
10
                    tooLong = true;
11
                }
11
                }
12
            }
12
            }
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)0.4
Clones locationClones are declared in the same class
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    74
    for (int i = 1; i <= alphaSize; i++)
    74
    for (int i = 1; i <= alphaSize; i++)
    75
    int j = 0;
    75
    int j = 0;
    76
    int k = i;
    76
    int k = i;
    77
    for (int parent_k; (parent_k = parent[k]) >= 0; )
    77
    for (int parent_k; (parent_k = parent[k]) >= 0; )
    78
    k = parent_k;
    78
    k = parent_k;
    79
    j++;
    79
    j++;
                                                  
    80
    len[i - 1] = (byte)j;
    Preondition Violations
    Unmatched statement len[i - 1]=(byte)j; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    80
    len[i - 1] = (byte)j;
    80
    len[i - 1] = (char)j;
    80
    len[i - 1] = (char)j;
    Preondition Violations
    Unmatched statement len[i - 1]=(char)j; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
    81
    if (j > maxLen)
    81
    if (j > maxLen)
    82
    tooLong = true;
    82
    tooLong = true;
    Precondition Violations (3)
    Row Violation
    1Unmatched statement len[i - 1]=(byte)j; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement len[i - 1]=(char)j; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables tooLong, i, j , while Clone fragment #2 returns variables tooLong, i, j