while (remaining > 0) { 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) { 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: 12 Number of AST nodes: 12
1
while (remaining > 0) {
1
while (remaining > 0) {
2
            while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
2
            while (remaining > 0 && b[offset] != LF && b[offset] != CR) {
3
                offset++;
3
                offset++;
4
                remaining--;
4
                remaining--;
5
            }
5
            }
6
            // either end of buffer or a line separator char
6
            // either end of buffer or a line separator char
7
            int blockLength = offset - blockStartOffset;
7
            int blockLength = offset - blockStartOffset;
8
            if (blockLength > 0) {
8
            if (blockLength > 0) {
9
                bufferInfo.buffer.write(b, blockStartOffset, blockLength);
9
                buffer.write(b, blockStartOffset, blockLength);
10
            }
10
            }
11
            while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
11
            while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
12
                write(b[offset]);
12
                write(b[offset]);
13
                offset++;
13
                offset++;
14
                remaining--;
14
                remaining--;
15
            }
15
            }
16
            blockStartOffset = offset;
16
            blockStartOffset = offset;
17
        }
17
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.1
Clones locationClones are in different classes having the same super class
Number of node comparisons71
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    while (remaining > 0)
    4
    while (remaining > 0)
    6
    while (remaining > 0 && b[offset] != LF && b[offset] != CR)
    5
    while (remaining > 0 && b[offset] != LF && b[offset] != CR)
    7
    offset++;
    6
    offset++;
    8
    remaining--;
    7
    remaining--;
    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);
    11
    bufferInfo.buffer.write(b, blockStartOffset, blockLength);
    10
    buffer.write(b, blockStartOffset, blockLength);
    Differences
    Expression1Expression2Difference
    bufferInfo.bufferbufferTYPE_COMPATIBLE_REPLACEMENT
    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
    write(b[offset]);
    12
    write(b[offset]);
    14
    offset++;
    13
    offset++;
    15
    remaining--;
    14
    remaining--;
    16
    blockStartOffset = offset;
    15
    blockStartOffset = offset;
    Precondition Violations (0)
    Row Violation