check(); DynamicScope scope = context.getCurrentScope(); ByteList value = str.getByteList(); if (pos <= value.realSize && pos >= 0) { int realSize = value.realSize; int begin = value.begin; Matcher matcher = preparePattern(str).matcher(value.bytes, begin, begin + realSize); int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE); if (result >= 0) { updateBackRef(context, str, scope, matcher).charOffsetUpdated = false;; return result; } } scope.setBackRef(context.getRuntime().getNil()); return -1;
check(); DynamicScope scope = context.getCurrentScope(); ByteList value = str.getByteList(); if (pos <= value.realSize && pos >= 0) { int realSize = value.realSize; int begin = value.begin; Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize); int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE); if (result >= 0) { updateBackRef(context, str, scope, matcher); return result; } } scope.setBackRef(context.getRuntime().getNil()); return -1;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyRegexp.java File path: /jruby-1.4.0/src/org/jruby/RubyRegexp.java
Method name: int search19(ThreadContext, RubyString, int, boolean) Method name: int search(ThreadContext, RubyString, int, boolean)
Number of AST nodes: 14 Number of AST nodes: 13
1
check();
1
check();
2
        DynamicScope scope = context.getCurrentScope();
2
        DynamicScope scope = context.getCurrentScope();
3
        ByteList value = str.getByteList();
3
        ByteList value = str.getByteList();
4
        if (pos <= value.realSize && pos >= 0) {
4
        if (pos <= value.realSize && pos >= 0) {
5
            int realSize = value.realSize;
5
            int realSize = value.realSize;
6
            int begin = value.begin;
6
            int begin = value.begin;
7
            Matcher matcher = preparePattern(str).matcher(value.bytes, begin, begin + realSize);
7
            Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize);
8
            int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE);
8
            int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE);
9
            if (result >= 0) {
9
            if (result >= 0) {
10
                updateBackRef(context, str, scope, matcher).charOffsetUpdated = false;;
10
                updateBackRef(context, str, scope, matcher);
11
                return result;
11
                return result;
12
            }
12
            }
13
        }
13
        }
14
        scope.setBackRef(context.getRuntime().getNil());
14
        scope.setBackRef(context.getRuntime().getNil());
15
        return -1;
15
        return -1;
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.3
Clones locationClones are declared in the same class
Number of node comparisons50
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    check();
    1
    check();
    2
    DynamicScope scope = context.getCurrentScope();
    2
    DynamicScope scope = context.getCurrentScope();
    3
    ByteList value = str.getByteList();
    3
    ByteList value = str.getByteList();
    4
    if (pos <= value.realSize && pos >= 0)
    4
    if (pos <= value.realSize && pos >= 0)
    5
    int realSize = value.realSize;
    5
    int realSize = value.realSize;
    6
    int begin = value.begin;
    6
    int begin = value.begin;
    7
    Matcher matcher = preparePattern(str).matcher(value.bytes, begin, begin + realSize);
    7
    Matcher matcher = preparePattern(str).matcher(value.bytes, begin, begin + realSize);
    7
    Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize);
    Differences
    Expression1Expression2Difference
    preparePattern(str)patternTYPE_COMPATIBLE_REPLACEMENT
    7
    Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize);
    8
    int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE);
    8
    int result = matcher.search(begin + pos, begin + (reverse ? 0 : realSize), Option.NONE);
    9
    if (result >= 0)
    9
    if (result >= 0)
                                                                                              
    10
    updateBackRef(context, str, scope, matcher);
    Preondition Violations
    Unmatched statement updateBackRef(context,str,scope,matcher); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    updateBackRef(context, str, scope, matcher);
    10
    updateBackRef(context, str, scope, matcher).charOffsetUpdated = false;
    10
    updateBackRef(context, str, scope, matcher).charOffsetUpdated = false;
    Preondition Violations
    Unmatched statement updateBackRef(context,str,scope,matcher).charOffsetUpdated=false; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                              
    11
    ;
              
    12
    return result;
    11
    return result;
    13
    scope.setBackRef(context.getRuntime().getNil());
    12
    scope.setBackRef(context.getRuntime().getNil());
    14
    return -1;
    13
    return -1;
    Precondition Violations (3)
    Row Violation
    1Unmatched statement updateBackRef(context,str,scope,matcher); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement updateBackRef(context,str,scope,matcher).charOffsetUpdated=false; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables scope, matcher , while Clone fragment #2 returns variables scope, matcher