Ruby runtime = context.getRuntime(); Encoding enc = checkDummyEncoding(); if (value.realSize == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.begin; int end = s + value.realSize; byte[]bytes = value.bytes; if (singleByteOptimizable(enc)) { return singleByteDowncase(runtime, bytes, s, end); } else { return multiByteDowncase(runtime, enc, bytes, s, end); }
Ruby runtime = context.getRuntime(); Encoding enc = checkDummyEncoding(); if (value.realSize == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.begin; int end = s + value.realSize; byte[]bytes = value.bytes; if (singleByteOptimizable(enc)) { return singleByteSwapcase(runtime, bytes, s, end); } else { return multiByteSwapcase(runtime, enc, bytes, s, end); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyString.java File path: /jruby-1.4.0/src/org/jruby/RubyString.java
Method name: IRubyObject downcase_bang19(ThreadContext) Method name: IRubyObject swapcase_bang19(ThreadContext)
Number of AST nodes: 12 Number of AST nodes: 12
1
Ruby runtime = context.getRuntime();
1
Ruby runtime = context.getRuntime();
2
        Encoding enc = checkDummyEncoding();
2
        Encoding enc = checkDummyEncoding();
3
        if (value.realSize == 0) {
3
        if (value.realSize == 0) {
4
            modifyCheck();
4
            modifyCheck();
5
            return runtime.getNil();
5
            return runtime.getNil();        
6
        }
6
        }
7
        modifyAndKeepCodeRange();
7
        modifyAndKeepCodeRange();
8
        int s = value.begin;
8
        int s = value.begin;
9
        int end = s + value.realSize;
9
        int end = s + value.realSize;
10
        byte[]bytes = value.bytes;
10
        byte[]bytes = value.bytes;
11
        if (singleByteOptimizable(enc)) {
11
        if (singleByteOptimizable(enc)) {
12
            return singleByteDowncase(runtime, bytes, s, end);
12
            return singleByteSwapcase(runtime, bytes, s, end);
13
        } else {
13
        } else {
14
            return multiByteDowncase(runtime, enc, bytes, s, end);
14
            return multiByteSwapcase(runtime, enc, bytes, s, end);
15
        }
15
        }
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 comparisons54
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)7.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
    2
    Encoding enc = checkDummyEncoding();
    2
    Encoding enc = checkDummyEncoding();
    3
    if (value.realSize == 0)
    3
    if (value.realSize == 0)
    4
    modifyCheck();
    4
    modifyCheck();
    5
    return runtime.getNil();
    5
    return runtime.getNil();
    6
    modifyAndKeepCodeRange();
    6
    modifyAndKeepCodeRange();
    7
    int s = value.begin;
    7
    int s = value.begin;
    8
    int end = s + value.realSize;
    8
    int end = s + value.realSize;
    9
    byte[] bytes = value.bytes;
    9
    byte[] bytes = value.bytes;
    10
    if (singleByteOptimizable(enc))
    10
    if (singleByteOptimizable(enc))
    11
    return singleByteDowncase(runtime, bytes, s, end);
    11
    return singleByteDowncase(runtime, bytes, s, end);
    11
    return singleByteSwapcase(runtime, bytes, s, end);
    Differences
    Expression1Expression2Difference
    singleByteDowncasesingleByteSwapcaseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression singleByteDowncase(runtime,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method singleByteDowncase
    Expression singleByteSwapcase(runtime,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method singleByteSwapcase
    11
    return singleByteSwapcase(runtime, bytes, s, end);
    else
    else
    12
    return multiByteDowncase(runtime, enc, bytes, s, end);
    12
    return multiByteDowncase(runtime, enc, bytes, s, end);
    12
    return multiByteSwapcase(runtime, enc, bytes, s, end);
    Differences
    Expression1Expression2Difference
    multiByteDowncasemultiByteSwapcaseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression multiByteDowncase(runtime,enc,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method multiByteDowncase
    Expression multiByteSwapcase(runtime,enc,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method multiByteSwapcase
    12
    return multiByteSwapcase(runtime, enc, bytes, s, end);
    Precondition Violations (4)
    Row Violation
    1Expression singleByteDowncase(runtime,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression singleByteSwapcase(runtime,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression multiByteDowncase(runtime,enc,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression multiByteSwapcase(runtime,enc,bytes,s,end) cannot be parameterized, because it has dependencies to/from statements that will be extracted