while (--posIndex >= min) { newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample }
for (current = newMatch; current != null; current = current.next) { // clone() separates a single match from the chain single = (REMatch) current.clone(); if (next(input, single)) { // chain results to doneIndex if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } // Find new doneIndexLast while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; } } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/RETokenRepeated.java File path: /jEdit-4.2/src/gnu/regexp/RETokenRepeated.java
Method name: boolean match(CharIndexed, REMatch) Method name: REMatch matchRest(CharIndexed, REMatch)
Number of AST nodes: 10 Number of AST nodes: 9
1
while (--posIndex >= min) {
2
	    newMatch = (REMatch) positions.elementAt(posIndex);
3
	    results = matchRest(input, newMatch);
4
	    if (results != null) {
5
		if (allResults
1
for (current = newMatch; current != null; current = current.next) {
2
	    // clone() separates a single match from the chain
3
	    single = (REMatch) current.clone();
4
	    if (next(input, single)) {
5
		// chain results to doneIndex
6
 == null) {
6
		if (doneIndex == null) {
7
		    allResults = results;
7
		    
8
		    allResultsLast = results;
9
		} else {
10
		    // Order these from longest to shortest
11
		    // Start by assuming longest (more repeats)
12
		    allResults
8
doneIndex = single;
9
		    doneIndexLast = single;
10
		} else {
13
Last.next = results;
11
		    doneIndexLast.next = single;
14
		}
12
		}
15
		// Find new doablesLast
13
		// Find new doneIndexLast
16
		while (allResultsLast.next != null) {
14
		while (doneIndexLast.next != null) {
17
		    allResultsLast = allResultsLast.next;
15
		    
18
		}
19
	    }
20
	    // else did not match rest of the tokens, try again on smaller sample
16
doneIndexLast = doneIndexLast.next;
17
		}
18
	    }
21
	}
19
	}
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 comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    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.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    42
    if (allResults == null)
    42
    if (allResults == null)
    7
    if (doneIndex == null)
    Differences
    Expression1Expression2Difference
    allResultsdoneIndexVARIABLE_NAME_MISMATCH
    7
    if (doneIndex == null)
    43
    allResults = results;
    43
    allResults = results;
    8
    doneIndex = single;
    Differences
    Expression1Expression2Difference
    allResultsdoneIndexVARIABLE_NAME_MISMATCH
    resultssingleVARIABLE_NAME_MISMATCH
    8
    doneIndex = single;
    44
    allResultsLast = results;
    44
    allResultsLast = results;
    9
    doneIndexLast = single;
    Differences
    Expression1Expression2Difference
    allResultsLastdoneIndexLastVARIABLE_NAME_MISMATCH
    resultssingleVARIABLE_NAME_MISMATCH
    9
    doneIndexLast = single;
    else
    else
    45
    allResultsLast.next = results;
    45
    allResultsLast.next = results;
    10
    doneIndexLast.next = single;
    Differences
    Expression1Expression2Difference
    allResultsLastdoneIndexLastVARIABLE_NAME_MISMATCH
    resultssingleVARIABLE_NAME_MISMATCH
    10
    doneIndexLast.next = single;
    46
    while (allResultsLast.next != null)
    46
    while (allResultsLast.next != null)
    11
    while (doneIndexLast.next != null)
    Differences
    Expression1Expression2Difference
    allResultsLastdoneIndexLastVARIABLE_NAME_MISMATCH
    11
    while (doneIndexLast.next != null)
    47
    allResultsLast = allResultsLast.next;
    47
    allResultsLast = allResultsLast.next;
    12
    doneIndexLast = doneIndexLast.next;
    Differences
    Expression1Expression2Difference
    allResultsLastdoneIndexLastVARIABLE_NAME_MISMATCH
    allResultsLastdoneIndexLastVARIABLE_NAME_MISMATCH
    12
    doneIndexLast = doneIndexLast.next;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables allResults, allResultsLast , while Clone fragment #2 returns variables doneIndex, doneIndexLast