while ((end = matcher.search(start, range, Option.NONE)) >= 0) { if (start == end + begin && matcher.getBegin() == matcher.getEnd()) { if (len == 0) { result.append(newEmptyString(runtime, getMetaClass())); break; } else if (lastNull) { result.append(makeShared19(runtime, beg, StringSupport.length(enc, bytes, begin + beg, range))); beg = start - begin; } else { start += start == range ? 1 : StringSupport.length(enc, bytes, start, range); lastNull = true; continue; } } else { result.append(makeShared19(runtime, beg, end - beg)); beg = matcher.getEnd(); start = begin + beg; } lastNull = false; if (captures) populateCapturesForSplit(runtime, result, matcher, true); if (limit && lim <= ++i) break; }
while ((end = matcher.search(start, range, Option.NONE)) >= 0) { if (start == end + begin && matcher.getBegin() == matcher.getEnd()) { if (len == 0) { result.append(newEmptyString(runtime, getMetaClass())); break; } else if (lastNull) { result.append(makeShared(runtime, beg, enc.length(bytes, begin + beg, range))); beg = start - begin; } else { start += start == range ? 1 : enc.length(bytes, start, range); lastNull = true; continue; } } else { result.append(makeShared(runtime, beg, end - beg)); beg = matcher.getEnd(); start = begin + beg; } lastNull = false; if (captures) populateCapturesForSplit(runtime, result, matcher, false); if (limit && lim <= ++i) break; }
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: RubyArray regexSplit19(ThreadContext, Regex, Regex, boolean, int, int) Method name: RubyArray regexSplit(ThreadContext, IRubyObject, boolean, int, int)
Number of AST nodes: 19 Number of AST nodes: 19
1
while ((end = matcher.search(start, range, Option.NONE)) >= 0) {
1
while ((end = matcher.search(start, range, Option.NONE)) >= 0) {
2
            if (start == end + begin && matcher.getBegin() == matcher.getEnd()) {
2
            if (start == end + begin && matcher.getBegin() == matcher.getEnd()) {
3
                if (len == 0) {
3
                if (len == 0) {
4
                    result.append(newEmptyString(runtime, getMetaClass()));
4
                    result.append(newEmptyString(runtime, getMetaClass()));
5
                    break;
5
                    break;
6
                } else if (lastNull) {
6
                } else if (lastNull) {
7
                    result.append(makeShared19(runtime, beg, StringSupport.length(enc, bytes, begin + beg, range)));
7
                    result.append(makeShared(runtime, beg, enc.length(bytes, begin + beg, range)));
8
                    beg = start - begin;
8
                    beg = start - begin;
9
                } else {
9
                } else {
10
                    start += start == range ? 1 : StringSupport.length(enc, bytes, start, range);
10
                    start += start == range ? 1 : enc.length(bytes, start, range);
11
                    lastNull = true;
11
                    lastNull = true;
12
                    continue;
12
                    continue;
13
                }
13
                }
14
            } else {
14
            } else {
15
                result.append(makeShared19(runtime, beg, end - beg));
15
                result.append(makeShared(runtime, beg, end - beg));
16
                beg = matcher.getEnd();
16
                beg = matcher.getEnd();
17
                start = begin + beg;
17
                start = begin + beg;
18
            }
18
            }
19
            lastNull = false;
19
            lastNull = false;
20
            if (captures) populateCapturesForSplit(runtime, result, matcher, true);
20
            if (captures) populateCapturesForSplit(runtime, result, matcher, false);
21
            if (limit && lim <= ++i) break;
21
            if (limit && lim <= ++i) break;
22
        }
22
        }
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)5.2
Clones locationClones are declared in the same class
Number of node comparisons97
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)59.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    13
    while ((end = matcher.search(start, range, Option.NONE)) >= 0)
    14
    while ((end = matcher.search(start, range, Option.NONE)) >= 0)
    14
    if (start == end + begin && matcher.getBegin() == matcher.getEnd())
    15
    if (start == end + begin && matcher.getBegin() == matcher.getEnd())
    15
    if (len == 0)
    16
    if (len == 0)
    16
    result.append(newEmptyString(runtime, getMetaClass()));
    17
    result.append(newEmptyString(runtime, getMetaClass()));
    17
    break;
    18
    break;
    18
    else if (lastNull)
    19
    else if (lastNull)
    19
    result.append(makeShared19(runtime, beg, StringSupport.length(enc, bytes, begin + beg, range)));
    19
    result.append(makeShared19(runtime, beg, StringSupport.length(enc, bytes, begin + beg, range)));
    Preondition Violations
    Unmatched statement result.append(makeShared19(runtime,beg,StringSupport.length(enc,bytes,begin + beg,range))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                  
                                                                                                                                                                  
    20
    result.append(makeShared(runtime, beg, enc.length(bytes, begin + beg, range)));
    Preondition Violations
    Unmatched statement result.append(makeShared(runtime,beg,enc.length(bytes,begin + beg,range))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20
    result.append(makeShared(runtime, beg, enc.length(bytes, begin + beg, range)));
    20
    beg = start - begin;
    21
    beg = start - begin;
    else
    else
    21
    start += start == range ? 1 : StringSupport.length(enc, bytes, start, range);
    21
    start += start == range ? 1 : StringSupport.length(enc, bytes, start, range);
    Preondition Violations
    Unmatched statement start+=start == range ? 1 : StringSupport.length(enc,bytes,start,range); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                            
                                                                                                                                
    22
    start += start == range ? 1 : enc.length(bytes, start, range);
    Preondition Violations
    Unmatched statement start+=start == range ? 1 : enc.length(bytes,start,range); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22
    start += start == range ? 1 : enc.length(bytes, start, range);
    22
    lastNull = true;
    23
    lastNull = true;
    23
    continue;
    24
    continue;
    else
    else
    24
    result.append(makeShared19(runtime, beg, end - beg));
    24
    result.append(makeShared19(runtime, beg, end - beg));
    25
    result.append(makeShared(runtime, beg, end - beg));
    Differences
    Expression1Expression2Difference
    makeShared19makeSharedMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression makeShared19(runtime,beg,end - beg) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression makeShared(runtime,beg,end - beg) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25
    result.append(makeShared(runtime, beg, end - beg));
    25
    beg = matcher.getEnd();
    26
    beg = matcher.getEnd();
    26
    start = begin + beg;
    27
    start = begin + beg;
    27
    lastNull = false;
    28
    lastNull = false;
    28
    if (captures)
    29
    if (captures)
    29
    populateCapturesForSplit(runtime, result, matcher, true);
    29
    populateCapturesForSplit(runtime, result, matcher, true);
    30
    populateCapturesForSplit(runtime, result, matcher, false);
    Differences
    Expression1Expression2Difference
    truefalseLITERAL_VALUE_MISMATCH
    30
    populateCapturesForSplit(runtime, result, matcher, false);
    30
    if (limit && lim <= ++i)
    31
    if (limit && lim <= ++i)
    31
    break;
    32
    break;
    Precondition Violations (7)
    Row Violation
    1Unmatched statement result.append(makeShared19(runtime,beg,StringSupport.length(enc,bytes,begin + beg,range))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement result.append(makeShared(runtime,beg,enc.length(bytes,begin + beg,range))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement start+=start == range ? 1 : StringSupport.length(enc,bytes,start,range); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement start+=start == range ? 1 : enc.length(bytes,start,range); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Expression makeShared19(runtime,beg,end - beg) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression makeShared(runtime,beg,end - beg) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Clone fragment #1 returns variables beg, start , while Clone fragment #2 returns variables beg, start