final DSymbolNode dsymbolNode = (DSymbolNode) node; ArrayCallback dstrCallback = new ArrayCallback() { public void nextValue(BodyCompiler context, Object sourceArray, int index) { compile(dsymbolNode.get(index), context, true); } }; boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ; boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr; if (doit) { context.createNewSymbol(dstrCallback, dsymbolNode.size()); if (popit) context.consumeCurrentValue(); } else { // not an expression, only compile the elements for (Node nextNode : dsymbolNode.childNodes()) { compile(nextNode, context, false); } }
final DStrNode dstrNode = (DStrNode) node; ArrayCallback dstrCallback = new ArrayCallback() { public void nextValue(BodyCompiler context, Object sourceArray, int index) { compile(dstrNode.get(index), context, true); } }; boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ; boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr; if (doit) { context.createNewString(dstrCallback, dstrNode.size()); if (popit) context.consumeCurrentValue(); } else { // not an expression, only compile the elements for (Node nextNode : dstrNode.childNodes()) { compile(nextNode, context, false); } }
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: void compileDSymbol(Node, BodyCompiler, boolean) Method name: void compileDStr(Node, BodyCompiler, boolean)
Number of AST nodes: 10 Number of AST nodes: 10
1
final DSymbolNode dsymbolNode = (DSymbolNode) node;
1
final DStrNode dstrNode = (DStrNode) node;
2
        ArrayCallback dstrCallback = new ArrayCallback() {
2
        ArrayCallback dstrCallback = new ArrayCallback() {
3
                    public void nextValue(BodyCompiler context, Object sourceArray,
3
                    public void nextValue(BodyCompiler context, Object sourceArray,
4
                            int index) {
4
                            int index) {
5
                        compile(dsymbolNode.get(index), context, true);
5
                        compile(dstrNode.get(index), context, true);
6
                    }
6
                    }
7
                };
7
                };
8
        boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ;
8
        boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ;
9
        boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr;
9
        boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr;
10
        if (doit) {
10
        if (doit) {
11
            context.createNewSymbol(dstrCallback, dsymbolNode.size());
11
            context.createNewString(dstrCallback, dstrNode.size());
12
            if (popit) context.consumeCurrentValue();
12
            if (popit) context.consumeCurrentValue();
13
        } else {
13
        } else {
14
            // not an expression, only compile the elements
14
            // not an expression, only compile the elements
15
            for (Node nextNode : dsymbolNode.childNodes()) {
15
            for (Node nextNode : dstrNode.childNodes()) {
16
                compile(nextNode, context, false);
16
                compile(nextNode, context, false);
17
            }
17
            }
18
        }
18
        }
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.4
Clones locationClones are declared in the same class
Number of node comparisons27
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)8.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    final DSymbolNode dsymbolNode = (DSymbolNode)node;
    1
    final DSymbolNode dsymbolNode = (DSymbolNode)node;
    1
    final DStrNode dstrNode = (DStrNode)node;
    Differences
    Expression1Expression2Difference
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    dsymbolNodedstrNodeVARIABLE_NAME_MISMATCH
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    1
    final DStrNode dstrNode = (DStrNode)node;
    2
    ArrayCallback dstrCallback = new ArrayCallback() {...};
    2
    ArrayCallback dstrCallback = new ArrayCallback() {...};
    2
    ArrayCallback dstrCallback = new ArrayCallback() {...};
    Differences
    Expression1Expression2Difference
    dsymbolNodedstrNodeVARIABLE_NAME_MISMATCH
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    2
    ArrayCallback dstrCallback = new ArrayCallback() {...};
    3
    boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ;
    3
    boolean doit = expr || !RubyInstanceConfig.PEEPHOLE_OPTZ;
    4
    boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr;
    4
    boolean popit = !RubyInstanceConfig.PEEPHOLE_OPTZ && !expr;
    5
    if (doit)
    5
    if (doit)
    6
    context.createNewSymbol(dstrCallback, dsymbolNode.size());
    6
    context.createNewSymbol(dstrCallback, dsymbolNode.size());
    6
    context.createNewString(dstrCallback, dstrNode.size());
    Differences
    Expression1Expression2Difference
    createNewSymbolcreateNewStringMETHOD_INVOCATION_NAME_MISMATCH
    dsymbolNodedstrNodeVARIABLE_NAME_MISMATCH
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression context.createNewSymbol(dstrCallback,dsymbolNode.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression context.createNewString(dstrCallback,dstrNode.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression context.createNewSymbol(dstrCallback,dsymbolNode.size()) is a void method call, and thus it cannot be parameterized
    Expression context.createNewString(dstrCallback,dstrNode.size()) is a void method call, and thus it cannot be parameterized
    6
    context.createNewString(dstrCallback, dstrNode.size());
    7
    if (popit)
    7
    if (popit)
    8
    context.consumeCurrentValue();
    8
    context.consumeCurrentValue();
    else
    else
    9
    for (Node nextNode : dsymbolNode.childNodes())
    9
    for (Node nextNode : dsymbolNode.childNodes())
    9
    for (Node nextNode : dstrNode.childNodes())
    Differences
    Expression1Expression2Difference
    dsymbolNodedstrNodeVARIABLE_NAME_MISMATCH
    org.jruby.ast.DSymbolNodeorg.jruby.ast.DStrNodeSUBCLASS_TYPE_MISMATCH
    9
    for (Node nextNode : dstrNode.childNodes())
    10
    compile(nextNode, context, false);
    10
    compile(nextNode, context, false);
    Precondition Violations (4)
    Row Violation
    1Expression context.createNewSymbol(dstrCallback,dsymbolNode.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression context.createNewString(dstrCallback,dstrNode.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression context.createNewSymbol(dstrCallback,dsymbolNode.size()) is a void method call, and thus it cannot be parameterized
    4Expression context.createNewString(dstrCallback,dstrNode.size()) is a void method call, and thus it cannot be parameterized