byte[] array = new byte[count]; io.get(offset, array, 0, array.length); RubyArray arr = RubyArray.newArray(runtime, array.length); for (int i = 0; i < array.length; ++i) { arr.add(Util.newUnsigned8(runtime, array[i])); } return arr;
double[] array = new double[count]; io.get(offset, array, 0, array.length); RubyArray arr = RubyArray.newArray(runtime, array.length); for (int i = 0; i < array.length; ++i) { arr.add(RubyFloat.newFloat(runtime, array[i])); } return arr;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/ext/ffi/MemoryUtil.java File path: /jruby-1.4.0/src/org/jruby/ext/ffi/MemoryUtil.java
Method name: IRubyObject getArrayOfUnsigned8(Ruby, MemoryIO, long, int) Method name: IRubyObject getArrayOfFloat64(Ruby, MemoryIO, long, int)
Number of AST nodes: 6 Number of AST nodes: 6
1
byte[] array = new byte[count];
1
double[] array = new double[count];
2
        io.get(offset, array, 0, array.length);
2
        io.get(offset, array, 0, array.length);
3
        RubyArray arr = RubyArray.newArray(runtime, array.length);
3
        RubyArray arr = RubyArray.newArray(runtime, array.length);
4
        for (int i = 0; i < array.length; ++i) {
4
        for (int i = 0; i < array.length; ++i) {
5
            arr.add(Util.newUnsigned8(runtime, array[i]));
5
            arr.add(RubyFloat.newFloat(runtime, array[i]));
6
        }
6
        }
7
        return arr;
7
        return arr;
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.2
Clones locationClones are declared in the same class
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                            
    1
    double[] array = new double[count];
    1
    byte[] array = new byte[count];
                                                                    
    2
    io.get(offset, array, 0, array.length);
    2
    io.get(offset, array, 0, array.length);
    2
    io.get(offset, array, 0, array.length);
    Differences
    Expression1Expression2Difference
    byte[]double[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable array does not match with type double[] of variable array
    • Make classes byte[] and double[] extend a common superclass
    2
    io.get(offset, array, 0, array.length);
    3
    RubyArray arr = RubyArray.newArray(runtime, array.length);
    3
    RubyArray arr = RubyArray.newArray(runtime, array.length);
    3
    RubyArray arr = RubyArray.newArray(runtime, array.length);
    Differences
    Expression1Expression2Difference
    byte[]double[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable array does not match with type double[] of variable array
    • Make classes byte[] and double[] extend a common superclass
    3
    RubyArray arr = RubyArray.newArray(runtime, array.length);
    4
    for (int i = 0; i < array.length; ++i)
    4
    for (int i = 0; i < array.length; ++i)
    4
    for (int i = 0; i < array.length; ++i)
    Differences
    Expression1Expression2Difference
    byte[]double[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type byte[] of variable array does not match with type double[] of variable array
    • Make classes byte[] and double[] extend a common superclass
    4
    for (int i = 0; i < array.length; ++i)
    5
    arr.add(Util.newUnsigned8(runtime, array[i]));
    5
    arr.add(Util.newUnsigned8(runtime, array[i]));
    5
    arr.add(RubyFloat.newFloat(runtime, array[i]));
    Differences
    Expression1Expression2Difference
    newUnsigned8newFloatMETHOD_INVOCATION_NAME_MISMATCH
    org.jruby.runtime.builtin.IRubyObjectorg.jruby.RubyFloatVARIABLE_TYPE_MISMATCH
    byte[]double[]VARIABLE_TYPE_MISMATCH
    org.jruby.ext.ffi.Utilorg.jruby.RubyFloatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression Util.newUnsigned8(runtime,array[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression RubyFloat.newFloat(runtime,array[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.jruby.runtime.builtin.IRubyObject of variable Util.newUnsigned8(runtime,array[i]) does not match with type org.jruby.RubyFloat of variable RubyFloat.newFloat(runtime,array[i])
    • Make classes org.jruby.runtime.builtin.IRubyObject and org.jruby.RubyFloat extend a common superclass
    Type byte[] of variable array does not match with type double[] of variable array
    • Make classes byte[] and double[] extend a common superclass
    Type org.jruby.ext.ffi.Util of variable Util does not match with type org.jruby.RubyFloat of variable RubyFloat
    • Make classes org.jruby.ext.ffi.Util and org.jruby.RubyFloat extend a common superclass
    5
    arr.add(RubyFloat.newFloat(runtime, array[i]));
    6
    return arr;
    6
    return arr;
    Precondition Violations (8)
    Row Violation
    1Type byte[] of variable array does not match with type double[] of variable array
    2Type byte[] of variable array does not match with type double[] of variable array
    3Type byte[] of variable array does not match with type double[] of variable array
    4Expression Util.newUnsigned8(runtime,array[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression RubyFloat.newFloat(runtime,array[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type org.jruby.runtime.builtin.IRubyObject of variable Util.newUnsigned8(runtime,array[i]) does not match with type org.jruby.RubyFloat of variable RubyFloat.newFloat(runtime,array[i])
    7Type byte[] of variable array does not match with type double[] of variable array
    8Type org.jruby.ext.ffi.Util of variable Util does not match with type org.jruby.RubyFloat of variable RubyFloat