File path: /jruby-1.4.0/src/org/jruby/util/Pack.java | File path: /jruby-1.4.0/src/org/jruby/util/Pack.java | |||
Method name: RubyString pack(Ruby, RubyArray, ByteList)
|
Method name: RubyString pack(Ruby, RubyArray, ByteList)
|
|||
Number of AST nodes: 17 | Number of AST nodes: 16 | |||
1 | int currentByte = 0;↵ | 1 | int currentByte = 0;↵ | |
2 | int padLength = 0;↵ | 2 | int padLength = 0;↵ | |
3 | if (occurrences > lCurElemString.length()) {↵ | 3 | if (occurrences > lCurElemString.length()) {↵ | |
4 | padLength = (occurrences - lCurElemString.length()) / 2 + occurrences % 2;↵ | 4 | padLength = (occurrences - lCurElemString.length()) / 2 + occurrences % 2;↵ | |
5 | occurrences = lCurElemString.length();↵ | 5 | occurrences = lCurElemString.length();↵ | |
6 | }↵ | 6 | }↵ | |
7 | for (int i = 0; i < occurrences;) {↵ | 7 | for (int i = 0; i < occurrences;) {↵ | |
8 | if ((lCurElemString.charAt(i++) & 1) != 0) {//if the low bit is set↵ | 8 | currentByte |= lCurElemString.charAt(i++) & 1;↵ | |
9 | currentByte |= 128; //set the high bit of the result↵ | 9 | // we filled up current byte↵ | |
10 | }↵ | |||
10 | ; append it and create next one↵ | |||
11 | if ((i & 7) == 0) {↵ | 11 | if ((i & 7) == 0) {↵ | |
12 | result.append((byte) (currentByte & 0xff));↵ | 12 | result.append((byte) (currentByte & 0xff));↵ | |
13 | currentByte = 0;↵ | 13 | currentByte = 0;↵ | |
14 | continue;↵ | 14 | continue;↵ | |
15 | }↵ | 15 | }↵ | |
16 | //if the index is not a multiple of 8, we are not on a byte boundary↵ | 16 | //if the index is not a multiple of 8, we are not on a byte boundary↵ | |
17 | currentByte >>= 1; //shift the byte↵ | 17 | currentByte <<= 1;↵ | |
18 | }↵ | 18 | }↵ | |
19 | if ((occurrences & 7) != 0) { //if the length is not a multiple of 8↵ | 19 | if ((occurrences & 7) != 0) { //if the length is not a multiple of 8↵ | |
20 | currentByte >>= 7 - (occurrences & 7); //we need to pad the last byte↵ | 20 | currentByte <<= 7 - (occurrences & 7); //we need to pad the last byte↵ | |
21 | result.append((byte) (currentByte & 0xff));↵ | 21 | result.append((byte) (currentByte & 0xff));↵ | |
22 | }↵ | 22 | }↵ | |
23 | //do some padding, I don't understand the padding strategy↵ | |||
24 | result.length(result.length() + padLength); | 23 |
| |
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) | 3.4 |
Clones location | Clones are in the same method |
Number of node comparisons | 64 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 13.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
85 | int currentByte = 0; | 104 | int currentByte = 0; | ||||
86 | int padLength = 0; | 105 | int padLength = 0; | ||||
87 | if (occurrences > lCurElemString.length()) | 106 | if (occurrences > lCurElemString.length()) | ||||
88 | padLength = (occurrences - lCurElemString.length()) / 2 + occurrences % 2; | 107 | padLength = (occurrences - lCurElemString.length()) / 2 + occurrences % 2; | ||||
89 | occurrences = lCurElemString.length(); | 108 | occurrences = lCurElemString.length(); | ||||
90 | for (int i = 0; i < occurrences; ) | 109 | for (int i = 0; i < occurrences; ) | ||||
91 | if ((lCurElemString.charAt(i++) & 1) != 0) |
| | ||||
92 | currentByte |= 128; |
| | ||||
|
| 110 | currentByte |= lCurElemString.charAt(i++) & 1; | ||||
93 | if ((i & 7) == 0) | 111 | if ((i & 7) == 0) | ||||
94 | result.append((byte)(currentByte & 0xff)); | 112 | result.append((byte)(currentByte & 0xff)); | ||||
95 | currentByte = 0; | 113 | currentByte = 0; | ||||
96 | continue; | 114 | continue; | ||||
97 | currentByte >>= 1; |
| | ||||
| 115 | currentByte <<= 1; | |||||
98 | if ((occurrences & 7) != 0) | 116 | if ((occurrences & 7) != 0) | ||||
99 | currentByte >>= 7 - (occurrences & 7); |
| | ||||
|
| 117 | currentByte <<= 7 - (occurrences & 7); | ||||
100 | result.append((byte)(currentByte & 0xff)); | 118 | result.append((byte)(currentByte & 0xff)); | ||||
101 | result.length(result.length() + padLength); | 119 | result.length(result.length() + padLength); |
Row | Violation |
---|---|
1 | Unmatched statement if((lCurElemString.charAt(i++) & 1) != 0) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement currentByte|=128; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement currentByte|=lCurElemString.charAt(i++) & 1; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement currentByte>>=1; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement currentByte>>=7 - (occurrences & 7); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement currentByte<<=7 - (occurrences & 7); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Clone fragment #1 returns variables i, currentByte, occurrences , while Clone fragment #2 returns variables currentByte, i, occurrences |