int slot = isDefined(name); if (slot >= 0) return slot; // This is perhaps innefficient timewise? Optimal spacewise growVariableNames(name); // Returns slot of variable return variableNames.length - 1;
int slot = exists(name); if (slot >= 0) return slot; // This is perhaps innefficient timewise? Optimal spacewise growVariableNames(name); // Returns slot of variable return variableNames.length - 1;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/parser/StaticScope.java File path: /jruby-1.4.0/src/org/jruby/parser/StaticScope.java
Method name: int addVariable(String) Method name: int addVariableThisScope(String)
Number of AST nodes: 5 Number of AST nodes: 5
1
int slot = isDefined(name); 
1
int slot = exists(name);
2
        if (slot >= 0) return slot;
2
        if (slot >= 0) return slot;
3
            
4
        // This is perhaps innefficient timewise?  Optimal spacewise
3
        // This is perhaps innefficient timewise?  Optimal spacewise
5
        growVariableNames(name);
4
        growVariableNames(name);
6
        
7
        // Returns slot of variable
5
        // Returns slot of variable
8
        return variableNames.length - 1;
6
        return variableNames.length - 1;
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)0.1
Clones locationClones are declared in the same class
Number of node comparisons9
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    int slot = isDefined(name);
    1
    int slot = isDefined(name);
    1
    int slot = exists(name);
    Differences
    Expression1Expression2Difference
    isDefinedexistsMETHOD_INVOCATION_NAME_MISMATCH
    1
    int slot = exists(name);
    2
    if (slot >= 0)
    2
    if (slot >= 0)
    3
    return slot;
    3
    return slot;
    4
    growVariableNames(name);
    4
    growVariableNames(name);
    5
    return variableNames.length - 1;
    5
    return variableNames.length - 1;
    Precondition Violations (0)
    Row Violation