if (scope != null && scope.getNumberOfVariables() >= 1) { switch (scope.getNumberOfVariables()) { case 1: methodCompiler.loadNil(); assignLocalVariable(0, false); break; case 2: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,false); break; case 3: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,false); break; case 4: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,true); assignLocalVariable(3,false); break; default: method.aload(methodCompiler.getVarsArrayIndex()); methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,true); assignLocalVariable(3,false); methodCompiler.loadRuntime(); methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class)); } }
if (scope != null && scope.getNumberOfVariables() >= 1) { switch (scope.getNumberOfVariables()) { case 1: methodCompiler.loadNil(); assignLocalVariable(0, false); break; case 2: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,false); break; case 3: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,false); break; case 4: methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,true); assignLocalVariable(3,false); break; default: method.aload(methodCompiler.getVarsArrayIndex()); methodCompiler.loadNil(); assignLocalVariable(0,true); assignLocalVariable(1,true); assignLocalVariable(2,true); assignLocalVariable(3,false); methodCompiler.loadRuntime(); methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class)); } }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/impl/HeapBasedVariableCompiler.java File path: /jruby-1.4.0/src/org/jruby/compiler/impl/HeapBasedVariableCompiler.java
Method name: void beginClass(CompilerCallback, StaticScope) Method name: void beginClosure(CompilerCallback, StaticScope)
Number of AST nodes: 33 Number of AST nodes: 33
1
if (scope != null && scope.getNumberOfVariables() >= 1) {
1
if (scope != null && scope.getNumberOfVariables() >= 1) {
2
            switch (scope.getNumberOfVariables()) {
2
            switch (scope.getNumberOfVariables()) {
3
            case 1:
3
            case 1:
4
                methodCompiler.loadNil();
4
                methodCompiler.loadNil();
5
                assignLocalVariable(0, false);
5
                assignLocalVariable(0, false);
6
                break;
6
                break;
7
            case 2:
7
            case 2:
8
                methodCompiler.loadNil();
8
                methodCompiler.loadNil();
9
                assignLocalVariable(0,true);
9
                assignLocalVariable(0,true);
10
                assignLocalVariable(1,false);
10
                assignLocalVariable(1,false);
11
                break;
11
                break;
12
            case 3:
12
            case 3:
13
                methodCompiler.loadNil();
13
                methodCompiler.loadNil();
14
                assignLocalVariable(0,true);
14
                assignLocalVariable(0,true);
15
                assignLocalVariable(1,true);
15
                assignLocalVariable(1,true);
16
                assignLocalVariable(2,false);
16
                assignLocalVariable(2,false);
17
                break;
17
                break;
18
            case 4:
18
            case 4:
19
                methodCompiler.loadNil();
19
                methodCompiler.loadNil();
20
                assignLocalVariable(0,true);
20
                assignLocalVariable(0,true);
21
                assignLocalVariable(1,true);
21
                assignLocalVariable(1,true);
22
                assignLocalVariable(2,true);
22
                assignLocalVariable(2,true);
23
                assignLocalVariable(3,false);
23
                assignLocalVariable(3,false);
24
                break;
24
                break;
25
            default:
25
            default:
26
                method.aload(methodCompiler.getVarsArrayIndex());
26
                method.aload(methodCompiler.getVarsArrayIndex());
27
                methodCompiler.loadNil();
27
                methodCompiler.loadNil();
28
                assignLocalVariable(0,true);
28
                assignLocalVariable(0,true);
29
                assignLocalVariable(1,true);
29
                assignLocalVariable(1,true);
30
                assignLocalVariable(2,true);
30
                assignLocalVariable(2,true);
31
                assignLocalVariable(3,false);
31
                assignLocalVariable(3,false);
32
                methodCompiler.loadRuntime();
32
                methodCompiler.loadRuntime();
33
                methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class));
33
                methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class));
34
            }
34
            }
35
        }
35
        }
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)1.4
Clones locationClones are declared in the same class
Number of node comparisons586
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements33
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)101.5
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    15
    if (scope != null && scope.getNumberOfVariables() >= 1)
    8
    if (scope != null && scope.getNumberOfVariables() >= 1)
    16
    switch (scope.getNumberOfVariables())
    9
    switch (scope.getNumberOfVariables())
    17
    case 1:
    10
    case 1:
    18
    methodCompiler.loadNil();
    11
    methodCompiler.loadNil();
    19
    assignLocalVariable(0, false);
    12
    assignLocalVariable(0, false);
    20
    break;
    13
    break;
    21
    case 2:
    14
    case 2:
    22
    methodCompiler.loadNil();
    15
    methodCompiler.loadNil();
    23
    assignLocalVariable(0, true);
    16
    assignLocalVariable(0, true);
    24
    assignLocalVariable(1, false);
    17
    assignLocalVariable(1, false);
    25
    break;
    18
    break;
    26
    case 3:
    19
    case 3:
    27
    methodCompiler.loadNil();
    20
    methodCompiler.loadNil();
    28
    assignLocalVariable(0, true);
    21
    assignLocalVariable(0, true);
    29
    assignLocalVariable(1, true);
    22
    assignLocalVariable(1, true);
    30
    assignLocalVariable(2, false);
    23
    assignLocalVariable(2, false);
    31
    break;
    24
    break;
    32
    case 4:
    25
    case 4:
    33
    methodCompiler.loadNil();
    26
    methodCompiler.loadNil();
    34
    assignLocalVariable(0, true);
    27
    assignLocalVariable(0, true);
    35
    assignLocalVariable(1, true);
    28
    assignLocalVariable(1, true);
    36
    assignLocalVariable(2, true);
    29
    assignLocalVariable(2, true);
    37
    assignLocalVariable(3, false);
    30
    assignLocalVariable(3, false);
    38
    break;
    31
    break;
    39
    default:
    32
    default:
    40
    method.aload(methodCompiler.getVarsArrayIndex());
    33
    method.aload(methodCompiler.getVarsArrayIndex());
    41
    methodCompiler.loadNil();
    34
    methodCompiler.loadNil();
    42
    assignLocalVariable(0, true);
    35
    assignLocalVariable(0, true);
    43
    assignLocalVariable(1, true);
    36
    assignLocalVariable(1, true);
    44
    assignLocalVariable(2, true);
    37
    assignLocalVariable(2, true);
    45
    assignLocalVariable(3, false);
    38
    assignLocalVariable(3, false);
    46
    methodCompiler.loadRuntime();
    39
    methodCompiler.loadRuntime();
    47
    methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class));
    40
    methodCompiler.invokeUtilityMethod("fillNil", sig(void.class, IRubyObject[].class, Ruby.class));
    Precondition Violations (0)
    Row Violation