int offset = off; int blockStartOffset = offset; int remaining = len; BufferInfo bufferInfo = getBufferInfo(); 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; }
int offset = off; int blockStartOffset = offset; int remaining = len; 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: 16 Number of AST nodes: 15
1
int offset = off;
1
int offset = off;
2
        int blockStartOffset = offset;
2
        int blockStartOffset = offset;
3
        int remaining = len;
3
        int remaining = len;
4
        BufferInfo bufferInfo = getBufferInfo();
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
            }
8
            }
10
            // either end of buffer or a line separator char
9
            // either end of buffer or a line separator char
11
            int blockLength = offset - blockStartOffset;
10
            int blockLength = offset - blockStartOffset;
12
            if (blockLength > 0) {
11
            if (blockLength > 0) {
13
                bufferInfo.buffer.write(b, blockStartOffset, blockLength);
12
                buffer.write(b, blockStartOffset, blockLength);
14
            }
13
            }
15
            while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
14
            while (remaining > 0 && (b[offset] == LF || b[offset] == CR)) {
16
                write(b[offset]);
15
                write(b[offset]);
17
                offset++;
16
                offset++;
18
                remaining--;
17
                remaining--;
19
            }
18
            }
20
            blockStartOffset = offset;
19
            blockStartOffset = offset;
21
        }
20
        }
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons83
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int offset = off;
    1
    int offset = off;
    2
    int blockStartOffset = offset;
    2
    int blockStartOffset = offset;
    3
    int remaining = len;
    3
    int remaining = len;
    4
    BufferInfo bufferInfo = getBufferInfo();
                                                                                      
    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