while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
offset++;
remaining--;
}
// either end of buffer or a line separator char
int blockLength = offset - blockStartOffset;
if (blockLength > 0) {
bufferInfo.buffer.write(b, blockStartOffset, blockLength);
}
while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
write(b[offset]);
offset++;
remaining--;
}
blockStartOffset = offset;
while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
offset++;
remaining--;
}
// either end of buffer or a line separator char
int blockLength = offset - blockStartOffset;
if (blockLength > 0) {
buffer.write(b, blockStartOffset, blockLength);
}
while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
write(b[offset]);
offset++;
remaining--;
}
blockStartOffset = offset;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/DemuxOutputStream.java
|
|
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/LineOrientedOutputStream.java
|
Method name: void write(byte[], int, int)
|
|
Method name: void write(byte[], int, int)
|
Number of AST nodes: 11
|
|
Number of AST nodes: 11
|
|
1 | while (remaining > 0 && b[offset] != LF && b[offset] != CR) {↵ | | 1 | while (remaining > 0 && b[offset] != LF && b[offset] != CR) {↵
|
2 | offset++;↵ | | 2 | offset++;↵
|
3 | remaining--;↵ | | 3 | remaining--;↵
|
4 | }↵ | | 4 | }↵
|
5 | // either end of buffer or a line separator char↵ | | 5 | // either end of buffer or a line separator char↵
|
6 | int blockLength = offset - blockStartOffset;↵ | | 6 | int blockLength = offset - blockStartOffset;↵
|
7 | if (blockLength > 0) {↵ | | 7 | if (blockLength > 0) {↵
|
8 | bufferInfo.buffer.write(b, blockStartOffset, blockLength);↵ | | 8 | buffer.write(b, blockStartOffset, blockLength);↵
|
9 | }↵ | | 9 | }↵
|
10 | while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {↵ | | 10 | while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {↵
|
11 | write(b[offset]);↵ | | 11 | write(b[offset]);↵
|
12 | offset++;↵ | | 12 | offset++;↵
|
13 | remaining--;↵ | | 13 | remaining--;↵
|
14 | }↵ | | 14 | }↵
|
15 | blockStartOffset = offset; | | 15 | blockStartOffset = offset;
|
See real code fragment |
|
See real code fragment |
Summary
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) | 0.8 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 67 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 11 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 3.7 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
6 | while (remaining > 0 && b[offset] != LF && b[offset] != CR) | | 5 | while (remaining > 0 && b[offset] != LF && b[offset] != CR) |
7 | | | 6 | |
8 | | | 7 | |
9 | int blockLength = offset - blockStartOffset; | | 8 | int blockLength = offset - blockStartOffset; |
10 | if (blockLength > 0) | | 9 | if (blockLength > 0) |
11 | bufferInfo.buffer.write(b, blockStartOffset, blockLength); | | 10 | buffer.write(b, blockStartOffset, blockLength); |
12 | while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) | | 11 | while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) |
13 | | | 12 | |
14 | | | 13 | |
15 | | | 14 | |
16 | blockStartOffset = offset; | | 15 | blockStartOffset = offset; |
Precondition Violations (1)
Row |
Violation |
1 | Clone fragment #1 returns variables remaining, offset, blockStartOffset , while Clone fragment #2 returns variables remaining, offset, blockStartOffset |