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