StrNode strNode = (StrNode)whenNode.getExpressionNodes(); if (strNode.getValue().length() == 1) { if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING) return null; if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_STRING; continue; } else { if (foundType != null && foundType != FastSwitchType.STRING) return null; if (foundType == null) foundType = FastSwitchType.STRING; continue; }
SymbolNode symbolNode = (SymbolNode)whenNode.getExpressionNodes(); if (symbolNode.getName().length() == 1) { if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL) return null; if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_SYMBOL; continue; } else { if (foundType != null && foundType != FastSwitchType.SYMBOL) return null; if (foundType == null) foundType = FastSwitchType.SYMBOL; continue; }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/ASTCompiler.java File path: /jruby-1.4.0/src/org/jruby/compiler/ASTCompiler.java
Method name: FastSwitchType getHomogeneousSwitchType(List) Method name: FastSwitchType getHomogeneousSwitchType(List)
Number of AST nodes: 12 Number of AST nodes: 12
1
StrNode strNode = (StrNode)whenNode.getExpressionNodes();
1
SymbolNode symbolNode = (SymbolNode)whenNode.getExpressionNodes();
2
                if (strNode.getValue().length() == 1) {
2
                if (symbolNode.getName().length() == 1) {
3
                    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING) return null;
3
                    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL) return null;
4
                    if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_STRING;
4
                    if (foundType == null) foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
5
                    continue;
5
                    continue;
6
                } else {
6
                } else {
7
                    if (foundType != null && foundType != FastSwitchType.STRING) return null;
7
                    if (foundType != null && foundType != FastSwitchType.SYMBOL) return null;
8
                    if (foundType == null) foundType = FastSwitchType.STRING;
8
                    if (foundType == null) foundType = FastSwitchType.SYMBOL;
9
                    continue;
9
                    continue;
10
                }
10
                }
Summary
Number of common nesting structure subtrees2
Number of refactorable cases2
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)2.0
Clones locationClones are in the same method
Number of node comparisons36
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    31
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING)
    31
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_STRING)
    44
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL)
    Differences
    Expression1Expression2Difference
    SINGLE_CHAR_STRINGSINGLE_CHAR_SYMBOLVARIABLE_NAME_MISMATCH
    44
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL)
    32
    return null;
    45
    return null;
    33
    if (foundType == null)
    46
    if (foundType == null)
    34
    foundType = FastSwitchType.SINGLE_CHAR_STRING;
    34
    foundType = FastSwitchType.SINGLE_CHAR_STRING;
    47
    foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
    Differences
    Expression1Expression2Difference
    SINGLE_CHAR_STRINGSINGLE_CHAR_SYMBOLVARIABLE_NAME_MISMATCH
    47
    foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
    Precondition Violations (0)
    Row Violation
  2. {Refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    36
    if (foundType != null && foundType != FastSwitchType.STRING)
    36
    if (foundType != null && foundType != FastSwitchType.STRING)
    44
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL)
    Differences
    Expression1Expression2Difference
    STRINGSINGLE_CHAR_SYMBOLVARIABLE_NAME_MISMATCH
    44
    if (foundType != null && foundType != FastSwitchType.SINGLE_CHAR_SYMBOL)
    37
    return null;
    45
    return null;
    38
    if (foundType == null)
    46
    if (foundType == null)
    39
    foundType = FastSwitchType.STRING;
    39
    foundType = FastSwitchType.STRING;
    47
    foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
    Differences
    Expression1Expression2Difference
    STRINGSINGLE_CHAR_SYMBOLVARIABLE_NAME_MISMATCH
    47
    foundType = FastSwitchType.SINGLE_CHAR_SYMBOL;
    Precondition Violations (0)
    Row Violation