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: 82 | Number of AST nodes: 82 | |||
1 | for (boolean tooLong = true; tooLong;) {↵ | 1 | for (boolean tooLong = true; tooLong;) {↵ | |
2 | tooLong = false;↵ | 2 | tooLong = false;↵ | |
3 | int nNodes = alphaSize;↵ | 3 | int nNodes = alphaSize;↵ | |
4 | int nHeap = 0;↵ | 4 | int nHeap = 0;↵ | |
5 | heap[0] = 0;↵ | 5 | heap[0] = 0;↵ | |
6 | weight[0] = 0;↵ | 6 | weight[0] = 0;↵ | |
7 | parent[0] = -2;↵ | 7 | parent[0] = -2;↵ | |
8 | for (int i = 1; i <= alphaSize; i++) {↵ | 8 | for (int i = 1; i <= alphaSize; i++) {↵ | |
9 | parent[i] = -1;↵ | 9 | parent[i] = -1;↵ | |
10 | nHeap++;↵ | 10 | nHeap++;↵ | |
11 | heap[nHeap] = i;↵ | 11 | heap[nHeap] = i;↵ | |
12 | int zz = nHeap;↵ | 12 | int zz = nHeap;↵ | |
13 | int tmp = heap[zz];↵ | 13 | int tmp = heap[zz];↵ | |
14 | while (weight[tmp] < weight[heap[zz >> 1]]) {↵ | 14 | while (weight[tmp] < weight[heap[zz >> 1]]) {↵ | |
15 | heap[zz] = heap[zz >> 1];↵ | 15 | heap[zz] = heap[zz >> 1];↵ | |
16 | zz >>= 1;↵ | 16 | zz >>= 1;↵ | |
17 | }↵ | 17 | }↵ | |
18 | heap[zz] = tmp;↵ | 18 | heap[zz] = tmp;↵ | |
19 | }↵ | 19 | }↵ | |
20 | // assert (nHeap < (MAX_ALPHA_SIZE + 2)) : nHeap;↵ | |||
21 | while (nHeap > 1) {↵ | 20 | while (nHeap > 1) {↵ | |
22 | int n1 = heap[1];↵ | 21 | int n1 = heap[1];↵ | |
23 | heap[1] = heap[nHeap];↵ | 22 | heap[1] = heap[nHeap];↵ | |
24 | nHeap--;↵ | 23 | nHeap--;↵ | |
25 | int yy = 0;↵ | 24 | int yy = 0;↵ | |
26 | int zz = 1;↵ | 25 | int zz = 1;↵ | |
27 | int tmp = heap[1];↵ | 26 | int tmp = heap[1];↵ | |
28 | while (true) {↵ | 27 | while (true) {↵ | |
29 | yy = zz << 1;↵ | 28 | yy = zz << 1;↵ | |
30 | if (yy > nHeap) {↵ | 29 | if (yy > nHeap) {↵ | |
31 | break;↵ | 30 | break;↵ | |
32 | }↵ | 31 | }↵ | |
33 | if ((yy < nHeap)↵ | 32 | if ((yy < nHeap)↵ | |
34 | && (weight[heap[yy + 1]] < weight[heap[yy]])) {↵ | 33 | && (weight[heap[yy + 1]] < weight[heap[yy]])) {↵ | |
35 | yy++;↵ | 34 | yy++;↵ | |
36 | }↵ | 35 | }↵ | |
37 | if (weight[tmp] < weight[heap[yy]]) {↵ | 36 | if (weight[tmp] < weight[heap[yy]]) {↵ | |
38 | break;↵ | 37 | break;↵ | |
39 | }↵ | 38 | }↵ | |
40 | heap[zz] = heap[yy];↵ | 39 | heap[zz] = heap[yy];↵ | |
41 | zz = yy;↵ | 40 | zz = yy;↵ | |
42 | }↵ | 41 | }↵ | |
43 | heap[zz] = tmp;↵ | 42 | heap[zz] = tmp;↵ | |
44 | int n2 = heap[1];↵ | 43 | int n2 = heap[1];↵ | |
45 | heap[1] = heap[nHeap];↵ | 44 | heap[1] = heap[nHeap];↵ | |
46 | nHeap--;↵ | 45 | nHeap--;↵ | |
47 | yy = 0;↵ | 46 | yy = 0;↵ | |
48 | zz = 1;↵ | 47 | zz = 1;↵ | |
49 | tmp = heap[1];↵ | 48 | tmp = heap[1];↵ | |
50 | while (true) {↵ | 49 | while (true) {↵ | |
51 | yy = zz << 1;↵ | 50 | yy = zz << 1;↵ | |
52 | if (yy > nHeap) {↵ | 51 | if (yy > nHeap) {↵ | |
53 | break;↵ | 52 | break;↵ | |
54 | }↵ | 53 | }↵ | |
55 | if ((yy < nHeap)↵ | 54 | if ((yy < nHeap)↵ | |
56 | && (weight[heap[yy + 1]] < weight[heap[yy]])) {↵ | 55 | && (weight[heap[yy + 1]] < weight[heap[yy]])) {↵ | |
57 | yy++;↵ | 56 | yy++;↵ | |
58 | }↵ | 57 | }↵ | |
59 | if (weight[tmp] < weight[heap[yy]]) {↵ | 58 | if (weight[tmp] < weight[heap[yy]]) {↵ | |
60 | break;↵ | 59 | break;↵ | |
61 | }↵ | 60 | }↵ | |
62 | heap[zz] = heap[yy];↵ | 61 | heap[zz] = heap[yy];↵ | |
63 | zz = yy;↵ | 62 | zz = yy;↵ | |
64 | }↵ | 63 | }↵ | |
65 | heap[zz] = tmp;↵ | 64 | heap[zz] = tmp;↵ | |
66 | nNodes++;↵ | 65 | nNodes++;↵ | |
67 | parent[n1] = parent[n2] = nNodes;↵ | 66 | parent[n1] = parent[n2] = nNodes;↵ | |
68 | final int weight_n1 = weight[n1];↵ | 67 | final int weight_n1 = weight[n1];↵ | |
69 | final int weight_n2 = weight[n2];↵ | 68 | final int weight_n2 = weight[n2];↵ | |
70 | weight[nNodes] = (((weight_n1 & 0xffffff00)↵ | 69 | weight[nNodes] = ((weight_n1 & 0xffffff00)↵ | |
71 | + (weight_n2 & 0xffffff00))↵ | 70 | + (weight_n2 & 0xffffff00))↵ | |
72 | | (1 + (((weight_n1 & 0x000000ff)↵ | 71 | | (1 + (((weight_n1 & 0x000000ff)↵ | |
73 | > (weight_n2 & 0x000000ff))↵ | 72 | > (weight_n2 & 0x000000ff))↵ | |
74 | ? (weight_n1 & 0x000000ff)↵ | 73 | ? (weight_n1 & 0x000000ff)↵ | |
75 | : (weight_n2 & 0x000000ff))));↵ | 74 | : (weight_n2 & 0x000000ff)));↵ | |
76 | ↵ | |||
77 | parent[nNodes] = -1;↵ | 75 | parent[nNodes] = -1;↵ | |
78 | nHeap++;↵ | 76 | nHeap++;↵ | |
79 | heap[nHeap] = nNodes;↵ | 77 | heap[nHeap] = nNodes;↵ | |
80 | tmp = 0;↵ | 78 | tmp = 0;↵ | |
81 | zz = nHeap;↵ | 79 | zz = nHeap;↵ | |
82 | tmp = heap[zz];↵ | 80 | tmp = heap[zz];↵ | |
83 | final int weight_tmp = weight[tmp];↵ | 81 | final int weight_tmp = weight[tmp];↵ | |
84 | while (weight_tmp < weight[heap[zz >> 1]]) {↵ | 82 | while (weight_tmp < weight[heap[zz >> 1]]) {↵ | |
85 | heap[zz] = heap[zz >> 1];↵ | 83 | heap[zz] = heap[zz >> 1];↵ | |
86 | zz >>= 1;↵ | 84 | zz >>= 1;↵ | |
87 | }↵ | 85 | }↵ | |
88 | heap[zz] = tmp;↵ | 86 | heap[zz] = tmp;↵ | |
89 | }↵ | 87 | }↵ | |
90 | // assert (nNodes < (MAX_ALPHA_SIZE * 2)) : nNodes;↵ | |||
91 | for (int i = 1; i <= alphaSize; i++) {↵ | 88 | for (int i = 1; i <= alphaSize; i++) {↵ | |
92 | int j = 0;↵ | 89 | int j = 0;↵ | |
93 | int k = i;↵ | 90 | int k = i;↵ | |
94 | for (int parent_k; (parent_k = parent[k]) >= 0;) {↵ | 91 | for (int parent_k; (parent_k = parent[k]) >= 0;) {↵ | |
95 | k = parent_k;↵ | 92 | k = parent_k;↵ | |
96 | j++;↵ | 93 | j++;↵ | |
97 | }↵ | 94 | }↵ | |
98 | len[i - 1] = (char) j;↵ | 95 | len[i - 1] = (byte) j;↵ | |
99 | if (j > maxLen) {↵ | 96 | if (j > maxLen) {↵ | |
100 | tooLong = true;↵ | 97 | tooLong = true;↵ | |
101 | }↵ | 98 | }↵ | |
102 | }↵ | 99 | }↵ | |
103 | if (tooLong) {↵ | 100 | if (tooLong) {↵ | |
104 | for (int i = 1; i < alphaSize; i++) {↵ | 101 | for (int i = 1; i < alphaSize; i++) {↵ | |
105 | int j = weight[i] >> 8;↵ | 102 | int j = weight[i] >> 8;↵ | |
106 | j = 1 + (j >> 1);↵ | 103 | j = 1 + (j >> 1);↵ | |
107 | weight[i] = j << 8;↵ | 104 | weight[i] = j << 8;↵ | |
108 | }↵ | 105 | }↵ | |
109 | }↵ | 106 | }↵ | |
110 | } | 107 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 29.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 1224 |
Number of mapped statements | 81 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 313.1 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | for (boolean tooLong = true; tooLong; ) | 6 | for (boolean tooLong = true; tooLong; ) | |||||||||||||
7 | tooLong = false; | 7 | tooLong = false; | |||||||||||||
8 | int nNodes = alphaSize; | 8 | int nNodes = alphaSize; | |||||||||||||
9 | int nHeap = 0; | 9 | int nHeap = 0; | |||||||||||||
10 | heap[0] = 0; | 10 | heap[0] = 0; | |||||||||||||
11 | weight[0] = 0; | 11 | weight[0] = 0; | |||||||||||||
12 | parent[0] = -2; | 12 | parent[0] = -2; | |||||||||||||
13 | for (int i = 1; i <= alphaSize; i++) | 13 | for (int i = 1; i <= alphaSize; i++) | |||||||||||||
14 | parent[i] = -1; | 14 | parent[i] = -1; | |||||||||||||
15 | nHeap++; | 15 | nHeap++; | |||||||||||||
16 | heap[nHeap] = i; | 16 | heap[nHeap] = i; | |||||||||||||
17 | int zz = nHeap; | 17 | int zz = nHeap; | |||||||||||||
18 | int tmp = heap[zz]; | 18 | int tmp = heap[zz]; | |||||||||||||
19 | while (weight[tmp] < weight[heap[zz >> 1]]) | 19 | while (weight[tmp] < weight[heap[zz >> 1]]) | |||||||||||||
20 | heap[zz] = heap[zz >> 1]; | 20 | heap[zz] = heap[zz >> 1]; | |||||||||||||
21 | zz >>= 1; | 21 | zz >>= 1; | |||||||||||||
22 | heap[zz] = tmp; | 22 | heap[zz] = tmp; | |||||||||||||
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))); | ||||||||||||
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; | |||||||||||||
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; | |||||||||||||
80 | len[i - 1] = (char)j; |
| | |||||||||||||
81 | if (j > maxLen) | 81 | if (j > maxLen) | |||||||||||||
82 | tooLong = true; | 82 | tooLong = true; | |||||||||||||
83 | if (tooLong) | 83 | if (tooLong) | |||||||||||||
84 | for (int i = 1; i < alphaSize; i++) | 84 | for (int i = 1; i < alphaSize; i++) | |||||||||||||
85 | int j = weight[i] >> 8; | 85 | int j = weight[i] >> 8; | |||||||||||||
86 | j = 1 + (j >> 1); | 86 | j = 1 + (j >> 1); | |||||||||||||
87 | weight[i] = j << 8; | 87 | weight[i] = j << 8; |
Row | Violation |
---|---|
1 | 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 |
2 | 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 |
3 | 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 |
4 | 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 |
5 | Clone fragment #1 returns variables i, j , while Clone fragment #2 returns variables i, j |