while (nHeap > 1) { int n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; int yy = 0; int zz = 1; int tmp = heap[1]; while (true) { yy = zz << 1; if (yy > nHeap) { break; } if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } if (weight[tmp] < weight[heap[yy]]) { break; } heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; int n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; yy = 0; zz = 1; tmp = heap[1]; while (true) { yy = zz << 1; if (yy > nHeap) { break; } if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } if (weight[tmp] < weight[heap[yy]]) { break; } heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; nNodes++; parent[n1] = parent[n2] = nNodes; final int weight_n1 = weight[n1]; final int weight_n2 = weight[n2]; weight[nNodes] = (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)))); parent[nNodes] = -1; nHeap++; heap[nHeap] = nNodes; tmp = 0; zz = nHeap; tmp = heap[zz]; final int weight_tmp = weight[tmp]; while (weight_tmp < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; }
while (nHeap > 1) { int n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; int yy = 0; int zz = 1; int tmp = heap[1]; while (true) { yy = zz << 1; if (yy > nHeap) { break; } if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } if (weight[tmp] < weight[heap[yy]]) { break; } heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; int n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; yy = 0; zz = 1; tmp = heap[1]; while (true) { yy = zz << 1; if (yy > nHeap) { break; } if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]])) { yy++; } if (weight[tmp] < weight[heap[yy]]) { break; } heap[zz] = heap[yy]; zz = yy; } heap[zz] = tmp; nNodes++; parent[n1] = parent[n2] = nNodes; final int weight_n1 = weight[n1]; final int weight_n2 = weight[n2]; weight[nNodes] = ((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))); parent[nNodes] = -1; nHeap++; heap[nHeap] = nNodes; tmp = 0; zz = nHeap; tmp = heap[zz]; final int weight_tmp = weight[tmp]; while (weight_tmp < weight[heap[zz >> 1]]) { heap[zz] = heap[zz >> 1]; zz >>= 1; } heap[zz] = tmp; }
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: 51 Number of AST nodes: 51
1
while (nHeap > 1) {
1
while (nHeap > 1) {
2
                int n1 = heap[1];
2
                int n1 = heap[1];
3
                heap[1] = heap[nHeap];
3
                heap[1] = heap[nHeap];
4
                nHeap--;
4
                nHeap--;
5
                int yy = 0;
5
                int yy = 0;
6
                int zz = 1;
6
                int zz = 1;
7
                int tmp = heap[1];
7
                int tmp = heap[1];
8
                while (true) {
8
                while (true) {
9
                    yy = zz << 1;
9
                    yy = zz << 1;
10
                    if (yy > nHeap) {
10
                    if (yy > nHeap) {
11
                        break;
11
                        break;
12
                    }
12
                    }
13
                    if ((yy < nHeap)
13
                    if ((yy < nHeap)
14
                        && (weight[heap[yy + 1]] < weight[heap[yy]])) {
14
                        && (weight[heap[yy + 1]] < weight[heap[yy]])) {
15
                        yy++;
15
                        yy++;
16
                    }
16
                    }
17
                    if (weight[tmp] < weight[heap[yy]]) {
17
                    if (weight[tmp] < weight[heap[yy]]) {
18
                        break;
18
                        break;
19
                    }
19
                    }
20
                    heap[zz] = heap[yy];
20
                    heap[zz] = heap[yy];
21
                    zz = yy;
21
                    zz = yy;
22
                }
22
                }
23
                heap[zz] = tmp;
23
                heap[zz] = tmp;
24
                int n2 = heap[1];
24
                int n2 = heap[1];
25
                heap[1] = heap[nHeap];
25
                heap[1] = heap[nHeap];
26
                nHeap--;
26
                nHeap--;
27
                yy = 0;
27
                yy = 0;
28
                zz = 1;
28
                zz = 1;
29
                tmp = heap[1];
29
                tmp = heap[1];
30
                while (true) {
30
                while (true) {
31
                    yy = zz << 1;
31
                    yy = zz << 1;
32
                    if (yy > nHeap) {
32
                    if (yy > nHeap) {
33
                        break;
33
                        break;
34
                    }
34
                    }
35
                    if ((yy < nHeap)
35
                    if ((yy < nHeap)
36
                        && (weight[heap[yy + 1]] < weight[heap[yy]])) {
36
                        && (weight[heap[yy + 1]] < weight[heap[yy]])) {
37
                        yy++;
37
                        yy++;
38
                    }
38
                    }
39
                    if (weight[tmp] < weight[heap[yy]]) {
39
                    if (weight[tmp] < weight[heap[yy]]) {
40
                        break;
40
                        break;
41
                    }
41
                    }
42
                    heap[zz] = heap[yy];
42
                    heap[zz] = heap[yy];
43
                    zz = yy;
43
                    zz = yy;
44
                }
44
                }
45
                heap[zz] = tmp;
45
                heap[zz] = tmp;
46
                nNodes++;
46
                nNodes++;
47
                parent[n1] = parent[n2] = nNodes;
47
                parent[n1] = parent[n2] = nNodes;
48
                final int weight_n1 = weight[n1];
48
                final int weight_n1 = weight[n1];
49
                final int weight_n2 = weight[n2];
49
                final int weight_n2 = weight[n2];
50
                weight[nNodes] = (((weight_n1 & 0xffffff00)
50
                weight[nNodes] = ((weight_n1 & 0xffffff00)
51
                                   + (weight_n2 & 0xffffff00))
51
                                  + (weight_n2 & 0xffffff00))
52
                                  | (1 + (((weight_n1 & 0x000000ff)
52
                    | (1 + (((weight_n1 & 0x000000ff)
53
                                           > (weight_n2 & 0x000000ff))
53
                             > (weight_n2 & 0x000000ff))
54
                                          ? (weight_n1 & 0x000000ff)
54
                            ? (weight_n1 & 0x000000ff)
55
                                          : (weight_n2 & 0x000000ff))));
55
                            : (weight_n2 & 0x000000ff)));
56
                
57
                parent[nNodes] = -1;
56
                parent[nNodes] = -1;
58
                nHeap++;
57
                nHeap++;
59
                heap[nHeap] = nNodes;
58
                heap[nHeap] = nNodes;
60
                tmp = 0;
59
                tmp = 0;
61
                zz = nHeap;
60
                zz = nHeap;
62
                tmp = heap[zz];
61
                tmp = heap[zz];
63
                final int weight_tmp = weight[tmp];
62
                final int weight_tmp = weight[tmp];
64
                while (weight_tmp < weight[heap[zz >> 1]]) {
63
                while (weight_tmp < weight[heap[zz >> 1]]) {
65
                    heap[zz] = heap[zz >> 1];
64
                    heap[zz] = heap[zz >> 1];
66
                    zz >>= 1;
65
                    zz >>= 1;
67
                }
66
                }
68
                heap[zz] = tmp;
67
                heap[zz] = tmp;
69
            }
68
            }
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)10.3
Clones locationClones are declared in the same class
Number of node comparisons943
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements51
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)239.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    23
    while (nHeap > 1)
    23
    while (nHeap > 1)
    24
    int n1 = heap[1];
    24
    int n1 = heap[1];
    25
    heap[1] = heap[nHeap];
    25
    heap[1] = heap[nHeap];
    26
    nHeap--;
    26
    nHeap--;
    27
    int yy = 0;
    27
    int yy = 0;
    28
    int zz = 1;
    28
    int zz = 1;
    29
    int tmp = heap[1];
    29
    int tmp = heap[1];
    30
    while (true)
    30
    while (true)
    31
    yy = zz << 1;
    31
    yy = zz << 1;
    32
    if (yy > nHeap)
    32
    if (yy > nHeap)
    33
    break;
    33
    break;
    34
    if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]]))
    34
    if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]]))
    35
    yy++;
    35
    yy++;
    36
    if (weight[tmp] < weight[heap[yy]])
    36
    if (weight[tmp] < weight[heap[yy]])
    37
    break;
    37
    break;
    38
    heap[zz] = heap[yy];
    38
    heap[zz] = heap[yy];
    39
    zz = yy;
    39
    zz = yy;
    40
    heap[zz] = tmp;
    40
    heap[zz] = tmp;
    41
    int n2 = heap[1];
    41
    int n2 = heap[1];
    42
    heap[1] = heap[nHeap];
    42
    heap[1] = heap[nHeap];
    43
    nHeap--;
    43
    nHeap--;
    44
    yy = 0;
    44
    yy = 0;
    45
    zz = 1;
    45
    zz = 1;
    46
    tmp = heap[1];
    46
    tmp = heap[1];
    47
    while (true)
    47
    while (true)
    48
    yy = zz << 1;
    48
    yy = zz << 1;
    49
    if (yy > nHeap)
    49
    if (yy > nHeap)
    50
    break;
    50
    break;
    51
    if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]]))
    51
    if ((yy < nHeap) && (weight[heap[yy + 1]] < weight[heap[yy]]))
    52
    yy++;
    52
    yy++;
    53
    if (weight[tmp] < weight[heap[yy]])
    53
    if (weight[tmp] < weight[heap[yy]])
    54
    break;
    54
    break;
    55
    heap[zz] = heap[yy];
    55
    heap[zz] = heap[yy];
    56
    zz = yy;
    56
    zz = yy;
    57
    heap[zz] = tmp;
    57
    heap[zz] = tmp;
    58
    nNodes++;
    58
    nNodes++;
    59
    parent[n1] = parent[n2] = nNodes;
    59
    parent[n1] = parent[n2] = nNodes;
    60
    final int weight_n1 = weight[n1];
    60
    final int weight_n1 = weight[n1];
    61
    final int weight_n2 = weight[n2];
    61
    final int weight_n2 = weight[n2];
    62
    weight[nNodes] = (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))));
    62
    weight[nNodes] = (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))));
    62
    weight[nNodes] = ((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)));
    Differences
    Expression1Expression2Difference
    (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))))((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)))TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)))) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    62
    weight[nNodes] = ((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)));
    63
    parent[nNodes] = -1;
    63
    parent[nNodes] = -1;
    64
    nHeap++;
    64
    nHeap++;
    65
    heap[nHeap] = nNodes;
    65
    heap[nHeap] = nNodes;
    66
    tmp = 0;
    66
    tmp = 0;
    67
    zz = nHeap;
    67
    zz = nHeap;
    68
    tmp = heap[zz];
    68
    tmp = heap[zz];
    69
    final int weight_tmp = weight[tmp];
    69
    final int weight_tmp = weight[tmp];
    70
    while (weight_tmp < weight[heap[zz >> 1]])
    70
    while (weight_tmp < weight[heap[zz >> 1]])
    71
    heap[zz] = heap[zz >> 1];
    71
    heap[zz] = heap[zz >> 1];
    72
    zz >>= 1;
    72
    zz >>= 1;
    73
    heap[zz] = tmp;
    73
    heap[zz] = tmp;
    Precondition Violations (3)
    Row Violation
    1Expression (((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff)))) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ((weight_n1 & 0xffffff00) + (weight_n2 & 0xffffff00)) | (1 + (((weight_n1 & 0x000000ff) > (weight_n2 & 0x000000ff)) ? (weight_n1 & 0x000000ff) : (weight_n2 & 0x000000ff))) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables parent, weight , while Clone fragment #2 returns variables parent, weight