final Ruby runtime = context.getRuntime(); final ThreadContext localContext = context; try { if (block.isGiven()) { callEach(runtime, context, self, new BlockCallback() { public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { checkContext(localContext, ctx, "any?"); IRubyObject larg = checkArgs(runtime, largs); if (block.yield(ctx, larg).isTrue()) { throw JumpException.SPECIAL_JUMP; } return runtime.getNil(); } }); } else { callEach(runtime, context, self, new BlockCallback() { public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { checkContext(localContext, ctx, "any?"); IRubyObject larg = checkArgs(runtime, largs); if (larg.isTrue()) { throw JumpException.SPECIAL_JUMP; } return runtime.getNil(); } }); } } catch (JumpException.SpecialJump sj) { return runtime.getTrue(); } return runtime.getFalse();
final Ruby runtime = context.getRuntime(); final ThreadContext localContext = context; try { if (block.isGiven()) { callEach(runtime, context, self, new BlockCallback() { public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { checkContext(localContext, ctx, "all?"); IRubyObject larg = checkArgs(runtime, largs); if (!block.yield(ctx, larg).isTrue()) { throw JumpException.SPECIAL_JUMP; } return runtime.getNil(); } }); } else { callEach(runtime, context, self, new BlockCallback() { public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { checkContext(localContext, ctx, "all?"); IRubyObject larg = checkArgs(runtime, largs); if (!larg.isTrue()) { throw JumpException.SPECIAL_JUMP; } return runtime.getNil(); } }); } } catch (JumpException.SpecialJump sj) { return runtime.getFalse(); } return runtime.getTrue();
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyEnumerable.java File path: /jruby-1.4.0/src/org/jruby/RubyEnumerable.java
Method name: IRubyObject any_p(ThreadContext, IRubyObject, Block) Method name: IRubyObject all_p(ThreadContext, IRubyObject, Block)
Number of AST nodes: 7 Number of AST nodes: 7
1
final Ruby runtime = context.getRuntime();
1
final Ruby runtime = context.getRuntime();
2
        final ThreadContext localContext = context;
2
        final ThreadContext localContext = context;
3
        try {
3
        try {
4
            if (block.isGiven()) {
4
            if (block.isGiven()) {
5
                callEach(runtime, context, self, new BlockCallback() {
5
                callEach(runtime, context, self, new BlockCallback() {
6
                    public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
6
                    public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
7
                        checkContext(localContext, ctx, "any?");
7
                        checkContext(localContext, ctx, "all?");
8
                        IRubyObject larg = checkArgs(runtime, largs);
8
                        IRubyObject larg = checkArgs(runtime, largs);
9
                        if (block.yield(ctx, larg).isTrue()) {
9
                        if (!block.yield(ctx, larg).isTrue()) {
10
                            throw JumpException.SPECIAL_JUMP;
10
                            throw JumpException.SPECIAL_JUMP;
11
                        }
11
                        }
12
                        return runtime.getNil();
12
                        return runtime.getNil();
13
                    }
13
                    }
14
                });
14
                });
15
            } else {
15
            } else {
16
                callEach(runtime, context, self, new BlockCallback() {
16
                callEach(runtime, context, self, new BlockCallback() {
17
                    public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
17
                    public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
18
                        checkContext(localContext, ctx, "any?");
18
                        checkContext(localContext, ctx, "all?");
19
                        IRubyObject larg = checkArgs(runtime, largs);
19
                        IRubyObject larg = checkArgs(runtime, largs);
20
                        if (larg.isTrue()) {
20
                        if (!larg.isTrue()) {
21
                            throw JumpException.SPECIAL_JUMP;
21
                            throw JumpException.SPECIAL_JUMP;
22
                        }
22
                        }
23
                        return runtime.getNil();
23
                        return runtime.getNil();
24
                    }
24
                    }
25
                });
25
                });
26
            }
26
            }
27
        } catch (JumpException.SpecialJump sj) {
27
        } catch (JumpException.SpecialJump sj) {
28
            return runtime.getTrue();
28
            return runtime.getFalse();
29
        }
29
        }
30
        return runtime.getFalse();
30
        return runtime.getTrue();
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)1.1
Clones locationClones are declared in the same class
Number of node comparisons19
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)25.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    final Ruby runtime = context.getRuntime();
    1
    final Ruby runtime = context.getRuntime();
    2
    final ThreadContext localContext = context;
    2
    final ThreadContext localContext = context;
    3
    try
    3
    try
    3
    try
    Differences
    Expression1Expression2Difference
    getTruegetFalseMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression runtime.getTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.getFalse() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    try
    4
    if (block.isGiven())
    4
    if (block.isGiven())
    5
    callEach(runtime, context, self, new BlockCallback() {...});
    5
    callEach(runtime, context, self, new BlockCallback() {...});
    5
    callEach(runtime, context, self, new BlockCallback() {...});
    Differences
    Expression1Expression2Difference
    "any?""all?"LITERAL_VALUE_MISMATCH
    block.yield(ctx,larg).isTrue()!block.yield(ctx,larg).isTrue()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression block.yield(ctx,larg).isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !block.yield(ctx,larg).isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    callEach(runtime, context, self, new BlockCallback() {...});
    else
    else
    6
    callEach(runtime, context, self, new BlockCallback() {...});
    6
    callEach(runtime, context, self, new BlockCallback() {...});
    6
    callEach(runtime, context, self, new BlockCallback() {...});
    Differences
    Expression1Expression2Difference
    "any?""all?"LITERAL_VALUE_MISMATCH
    larg.isTrue()!larg.isTrue()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression larg.isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !larg.isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    callEach(runtime, context, self, new BlockCallback() {...});
    7
    return runtime.getFalse();
    7
    return runtime.getFalse();
    7
    return runtime.getTrue();
    Differences
    Expression1Expression2Difference
    getFalsegetTrueMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression runtime.getFalse() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.getTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    return runtime.getTrue();
    Precondition Violations (8)
    Row Violation
    1Expression runtime.getTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression runtime.getFalse() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression block.yield(ctx,larg).isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression !block.yield(ctx,larg).isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression larg.isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression !larg.isTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression runtime.getFalse() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression runtime.getTrue() cannot be parameterized, because it has dependencies to/from statements that will be extracted