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;
if (this.ignoreCase) return this.matchesIgnoreCase(chars, 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 = chars[--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(String, int, int) Method name: int matches(char[], int, int)
Number of AST nodes: 19 Number of AST nodes: 19
1
if (this.ignoreCase)
1
if (this.ignoreCase)
2
        return this.matchesIgnoreCase(str, start, limit);
2
        return this.matchesIgnoreCase(chars, 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
        //System.err.println("Starts at "+index);
10
        int pindex = plength;
10
        int pindex = plength;
11
        int nindex = index + 1;
11
        int nindex = index + 1;
12
        char ch;
12
        char ch;
13
        do
13
        do
14
        {
14
        {
15
          if ((ch = str.charAt(--index)) != this.pattern[--pindex])
15
          if ((ch = chars[--index]) != this.pattern[--pindex])
16
            break;
16
            break;
17
          if (pindex == 0)
17
          if (pindex == 0)
18
            return index;
18
            return index;
19
        }
19
        }
20
        while (pindex > 0);
20
        while (pindex > 0);
21
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
21
        index += this.shiftTable[ch % this.shiftTable.length] + 1;
22
        if (index < nindex)
22
        if (index < nindex)
23
          index = nindex;
23
          index = nindex;
24
      }
24
      }
25
      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)0.8
Clones locationClones are declared in the same class
Number of node comparisons67
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (this.ignoreCase)
    1
    if (this.ignoreCase)
    2
    return this.matchesIgnoreCase(str, start, limit);
    2
    return this.matchesIgnoreCase(str, start, limit);
    2
    return this.matchesIgnoreCase(chars, start, limit);
    Differences
    Expression1Expression2Difference
    strcharsVARIABLE_NAME_MISMATCH
    java.lang.Stringchar[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable str does not match with type char[] of variable chars
    • Make classes java.lang.String and char[] extend a common superclass
    2
    return this.matchesIgnoreCase(chars, 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])
    11
    if ((ch = str.charAt(--index)) != this.pattern[--pindex])
    11
    if ((ch = chars[--index]) != this.pattern[--pindex])
    Differences
    Expression1Expression2Difference
    str.charAt(--index)chars[--index]TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression str.charAt(--index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression chars[--index] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    if ((ch = chars[--index]) != this.pattern[--pindex])
    12
    break;
    12
    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;
    19
    return -1;
    19
    return -1;
    Precondition Violations (3)
    Row Violation
    1Type java.lang.String of variable str does not match with type char[] of variable chars
    2Expression str.charAt(--index) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression chars[--index] cannot be parameterized, because it has dependencies to/from statements that will be extracted