if (expr.match(stream, mymatch)) { mymatch.end[0] = mymatch.index; mymatch.finish(stream); stream.move(mymatch.toString().length()); offset += mymatch.toString().length(); buffer = mymatch.substituteInto(replace); bufpos = 1; // This is prone to infinite loops if replace string turns out empty. if (buffer.length() > 0) { return buffer.charAt(0); } }
if (expr.match(stream,mymatch)) { mymatch.end[0] = mymatch.index; mymatch.finish(stream); stream.move(mymatch.toString().length()); offset += mymatch.toString().length(); buffer = mymatch.substituteInto(replace); bufpos = 1; if (buffer.length() > 0) { return buffer.charAt(0); } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/REFilterInputStream.java File path: /jEdit-4.2/src/gnu/regexp/REFilterReader.java
Method name: int read() Method name: int read()
Number of AST nodes: 9 Number of AST nodes: 9
1
if (expr.match(stream, mymatch)) {
1
if (expr.match(stream,mymatch)) {
2
      mymatch.end[0] = mymatch.index;
2
      mymatch.end[0] = mymatch.index;
3
      mymatch.finish(stream);
3
      mymatch.finish(stream);
4
      stream.move(mymatch.toString().length());
4
      stream.move(mymatch.toString().length());
5
      offset += mymatch.toString().length();
5
      offset += mymatch.toString().length();
6
      buffer = mymatch.substituteInto(replace);
6
      buffer = mymatch.substituteInto(replace);
7
      bufpos = 1;
7
      bufpos = 1;
8
      // This is prone to infinite loops if replace string turns out empty.
9
      if (buffer.length() > 0) {
8
      if (buffer.length() > 0) {
10
	  return buffer.charAt(0);
9
	  return buffer.charAt(0);
11
      }
10
      }
12
    }
11
    }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes
Number of node comparisons53
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    if (expr.match(stream, mymatch))
    6
    if (expr.match(stream, mymatch))
    6
    if (expr.match(stream, mymatch))
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream
    • Make classes gnu.regexp.CharIndexedInputStream and gnu.regexp.CharIndexedReader extend a common superclass
    6
    if (expr.match(stream, mymatch))
    7
    mymatch.end[0] = mymatch.index;
    7
    mymatch.end[0] = mymatch.index;
    8
    mymatch.finish(stream);
    8
    mymatch.finish(stream);
    8
    mymatch.finish(stream);
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream
    • Make classes gnu.regexp.CharIndexedInputStream and gnu.regexp.CharIndexedReader extend a common superclass
    8
    mymatch.finish(stream);
    9
    stream.move(mymatch.toString().length());
    9
    stream.move(mymatch.toString().length());
    9
    stream.move(mymatch.toString().length());
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream
    • Make classes gnu.regexp.CharIndexedInputStream and gnu.regexp.CharIndexedReader extend a common superclass
    9
    stream.move(mymatch.toString().length());
    10
    offset += mymatch.toString().length();
    10
    offset += mymatch.toString().length();
    11
    buffer = mymatch.substituteInto(replace);
    11
    buffer = mymatch.substituteInto(replace);
    12
    bufpos = 1;
    12
    bufpos = 1;
    13
    if (buffer.length() > 0)
    13
    if (buffer.length() > 0)
    14
    return buffer.charAt(0);
    14
    return buffer.charAt(0);
    Precondition Violations (3)
    Row Violation
    1Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream
    2Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream
    3Type gnu.regexp.CharIndexedInputStream of variable stream does not match with type gnu.regexp.CharIndexedReader of variable stream