switch (specificArity) { default: case -1: if (getsBlock) { // variable args with block mv.visitVarInsn(ALOAD, BLOCK_INDEX); } else { // variable args no block, load null block mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class)); } break; case 0: if (getsBlock) { // zero args with block // FIXME: omit args index; subtract one from normal block index mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1); } else { // zero args, no block; load NULL_BLOCK mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class)); } break; case 1: if (getsBlock) { // one arg with block mv.visitVarInsn(ALOAD, BLOCK_INDEX); } else { // one arg, no block; load NULL_BLOCK mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class)); } break; case 2: if (getsBlock) { // two args with block mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1); } else { // two args, no block; load NULL_BLOCK mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class)); } break; case 3: if (getsBlock) { // three args with block mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2); } else { // three args, no block; load NULL_BLOCK mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class)); } break; }
switch (specificArity) { default: case -1: if (getsBlock) { // all other arg cases with block mv.visitVarInsn(ALOAD, BLOCK_INDEX); } else { // all other arg cases without block } break; case 0: if (getsBlock) { mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1); } else { // zero args, no block; do nothing } break; case 1: if (getsBlock) { mv.visitVarInsn(ALOAD, BLOCK_INDEX); } else { // one arg, no block; do nothing } break; case 2: if (getsBlock) { mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1); } else { // two args, no block; do nothing } break; case 3: if (getsBlock) { mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2); } else { // three args, no block; do nothing } break; }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/internal/runtime/methods/InvocationMethodFactory.java File path: /jruby-1.4.0/src/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
Method name: void loadBlockForPre(SkinnyMethodAdapter, int, boolean) Method name: void loadBlock(SkinnyMethodAdapter, int, boolean)
Number of AST nodes: 27 Number of AST nodes: 22
1
switch (specificArity) {
1
switch (specificArity) {
2
        default:
2
        default:
3
        case -1:
3
        case -1:
4
            if (getsBlock) {
4
            if (getsBlock) {
5
                // variable args with block
5
                // all other arg cases with block
6
                mv.visitVarInsn(ALOAD, BLOCK_INDEX);
6
                mv.visitVarInsn(ALOAD, BLOCK_INDEX);
7
            } else {
7
            } else {
8
                // variable args no block, load null block
8
                // 
9
                mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
10
            }
11
            break;
12
        case 0:
13
            if (getsBlock) {
14
                // zero args with block
15
                // FIXME: omit args index; subtract one from normal block index
9
all other arg cases without block
10
            }
11
            break;
12
        case 0:
13
            if (getsBlock) {
16
                mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1);
14
                mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1);
17
            } else {
15
            } else {
18
                // zero args, no block; load NULL_BLOCK
16
                // zero args, no block; 
19
                mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
17
do nothing
20
            }
18
            }
21
            break;
19
            break;
22
        case 1:
20
        case 1:
23
            if (getsBlock) {
21
            if (getsBlock) {
24
                // one arg with block
25
                mv.visitVarInsn(ALOAD, BLOCK_INDEX);
22
                mv.visitVarInsn(ALOAD, BLOCK_INDEX);
26
            } else {
23
            } else {
27
                // one arg, no block; load NULL_BLOCK
24
                // one arg, no block; 
28
                mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
25
do nothing
29
            }
26
            }
30
            break;
27
            break;
31
        case 2:
28
        case 2:
32
            if (getsBlock) {
29
            if (getsBlock) {
33
                // two args with block
34
                mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1);
30
                mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1);
35
            } else {
31
            } else {
36
                // two args, no block; load NULL_BLOCK
32
                // two args, no block; 
37
                mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
33
do nothing
38
            }
34
            }
39
            break;
35
            break;
40
        case 3:
36
        case 3:
41
            if (getsBlock) {
37
            if (getsBlock) {
42
                // three args with block
43
                mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2);
38
                mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2);
44
            } else {
39
            } else {
45
                // three args, no block; load NULL_BLOCK
40
                // three args, no block; 
46
                mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
41
do nothing
47
            }
42
            }
48
            break;
43
            break;
49
        }
44
        }
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.8
Clones locationClones are declared in the same class
Number of node comparisons172
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements22
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)23.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    switch (specificArity)
    1
    switch (specificArity)
    2
    default:
    2
    default:
    3
    case -1:
    3
    case -1:
    4
    if (getsBlock)
    4
    if (getsBlock)
    5
    mv.visitVarInsn(ALOAD, BLOCK_INDEX);
    5
    mv.visitVarInsn(ALOAD, BLOCK_INDEX);
    else
            
    6
    mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
                                                                                                                              
    7
    break;
    6
    break;
    8
    case 0:
    7
    case 0:
    9
    if (getsBlock)
    8
    if (getsBlock)
    10
    mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1);
    9
    mv.visitVarInsn(ALOAD, BLOCK_INDEX - 1);
    else
            
    11
    mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
                                                                                                                                
    12
    break;
    10
    break;
    13
    case 1:
    11
    case 1:
    14
    if (getsBlock)
    12
    if (getsBlock)
    15
    mv.visitVarInsn(ALOAD, BLOCK_INDEX);
    13
    mv.visitVarInsn(ALOAD, BLOCK_INDEX);
    else
            
    16
    mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
                                                                                                                                
    17
    break;
    14
    break;
    18
    case 2:
    15
    case 2:
    19
    if (getsBlock)
    16
    if (getsBlock)
    20
    mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1);
    17
    mv.visitVarInsn(ALOAD, BLOCK_INDEX + 1);
    else
            
    21
    mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
                                                                                                                                
    22
    break;
    18
    break;
    23
    case 3:
    19
    case 3:
    24
    if (getsBlock)
    20
    if (getsBlock)
    25
    mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2);
    21
    mv.visitVarInsn(ALOAD, BLOCK_INDEX + 2);
    else
            
    26
    mv.getstatic(p(Block.class), "NULL_BLOCK", ci(Block.class));
                                                                                                                                
    27
    break;
    22
    break;
    Precondition Violations (0)
    Row Violation