if (this.ignoreCase) return this.matchesIgnoreCase(iterator, start, limit); int plength = this.pattern.length; if (plength == 0) return start; int index = start + plength; while (index <= limit) { int pindex = plength; int nindex = index + 1; char ch; do { if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex]) break; if (pindex == 0) return index; } while (pindex > 0); index += this.shiftTable[ch % this.shiftTable.length] + 1; if (index < nindex) index = nindex; } return -1;
if (this.ignoreCase) return this.matchesIgnoreCase(str, start, limit); int plength = this.pattern.length; if (plength == 0) return start; int index = start + plength; while (index <= limit) { //System.err.println("Starts at "+index); int pindex = plength; int nindex = index + 1; char ch; do { if ((ch = str.charAt(--index)) != this.pattern[--pindex]) break; if (pindex == 0) return index; } while (pindex > 0); index += this.shiftTable[ch % this.shiftTable.length] + 1; if (index < nindex) index = nindex; } return -1;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/RegEx.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/RegEx.java
Method name: int matches(CharacterIterator, int, int) Method name: int matches(String, int, int)
Number of AST nodes: 19 Number of AST nodes: 19
1
if (this.ignoreCase)
1
if (this.ignoreCase)
2
        return this.matchesIgnoreCase(iterator, start, limit);
2
        return this.matchesIgnoreCase(str, start, limit);
3
      int plength = this.pattern.length;
3
      int plength = this.pattern.length;
4
      if (plength == 0)
4
      if (plength == 0)
5
        return start;
5
        return start;
6
      int index = start + plength;
6
      int index = start + plength;
7
      while (index <= limit)
7
      while (index <= limit)
8
      {
8
      {
9
        //System.err.println("Starts at "+index);
9
        int pindex = plength;
10
        int pindex = plength;
10
        int nindex = index + 1;
11
        int nindex = index + 1;
11
        char ch;
12
        char ch;
12
        do
13
        do
13
        {
14
        {
14
          if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
15
          if ((ch = str.charAt(--index)) != this.pattern[--pindex])
15
            break;
16
            break;
16
          if (pindex == 0)
17
          if (pindex == 0)
17
            return index;
18
            return index;
18
        }
19
        }
19
        while (pindex > 0);
20
        while (pindex > 0);
20
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
21
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
21
        if (index < nindex)
22
        if (index < nindex)
22
          index = nindex;
23
          index = nindex;
23
      }
24
      }
24
      return -1;
25
      return -1;
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)1.1
Clones locationClones are declared in the same class
Number of node comparisons56
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (this.ignoreCase)
    1
    if (this.ignoreCase)
    2
    return this.matchesIgnoreCase(iterator, start, limit);
    2
    return this.matchesIgnoreCase(iterator, start, limit);
    2
    return this.matchesIgnoreCase(str, start, limit);
    Differences
    Expression1Expression2Difference
    iteratorstrVARIABLE_NAME_MISMATCH
    java.text.CharacterIteratorjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.text.CharacterIterator of variable iterator does not match with type java.lang.String of variable str
    • Make classes java.text.CharacterIterator and java.lang.String extend a common superclass
    2
    return this.matchesIgnoreCase(str, start, limit);
    3
    int plength = this.pattern.length;
    3
    int plength = this.pattern.length;
    4
    if (plength == 0)
    4
    if (plength == 0)
    5
    return start;
    5
    return start;
    6
    int index = start + plength;
    6
    int index = start + plength;
    7
    while (index <= limit)
    7
    while (index <= limit)
    8
    int pindex = plength;
    8
    int pindex = plength;
    9
    int nindex = index + 1;
    9
    int nindex = index + 1;
    10
    char ch;
    10
    char ch;
    15
    do while(pindex > 0)
    15
    do while(pindex > 0)
                                                                                                                        
    11
    if ((ch = str.charAt(--index)) != this.pattern[--pindex])
    Preondition Violations
    Unmatched statement if((ch=str.charAt(--index)) != this.pattern[--pindex]) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    if ((ch = str.charAt(--index)) != this.pattern[--pindex])
                        
    12
    break;
    Preondition Violations
    Unmatched break;
    12
    break;
    11
    if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
    11
    if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
    Preondition Violations
    Unmatched statement if((ch=iterator.setIndex(--index)) != this.pattern[--pindex]) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                      
    12
    break;
    12
    break;
    Preondition Violations
    Unmatched break;
                        
    13
    if (pindex == 0)
    13
    if (pindex == 0)
    14
    return index;
    14
    return index;
    16
    index += this.shiftTable[ch % this.shiftTable.length] + 1;
    16
    index += this.shiftTable[ch % this.shiftTable.length] + 1;
    17
    if (index < nindex)
    17
    if (index < nindex)
    18
    index = nindex;
    18
    index = nindex;
    Precondition Violations (6)
    Row Violation
    1Type java.text.CharacterIterator of variable iterator does not match with type java.lang.String of variable str
    2Unmatched statement if((ch=str.charAt(--index)) != this.pattern[--pindex]) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched break;
    4Unmatched statement if((ch=iterator.setIndex(--index)) != this.pattern[--pindex]) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched break;
    6Clone fragment #1 returns variables index, pindex, ch , while Clone fragment #2 returns variables index, pindex, ch