Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 27c0c653ce37
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ba60fb500eb9
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Feb 5, 2015

  1. Exit iterator when RubyHash#any? short-circuits

    Previously, if `any?` returned true early (or threw an exception) the
    hash would be marked as still iterating, and thus prevent updates.
    grddev committed Feb 5, 2015
    Copy the full SHA
    2775f44 View commit details
  2. Merge pull request #2568 from grddev/fix-hash-any

    Exit iterator when `RubyHash#any?` short-circuits
    enebo committed Feb 5, 2015
    Copy the full SHA
    ba60fb5 View commit details
Showing with 17 additions and 13 deletions.
  1. +17 −13 core/src/main/java/org/jruby/RubyHash.java
30 changes: 17 additions & 13 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -1892,25 +1892,29 @@ public IRubyObject any_p(ThreadContext context, Block block) {

private IRubyObject any_p_i(ThreadContext context, Block block) {
iteratorEntry();
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
IRubyObject newAssoc = RubyArray.newArray(context.runtime, entry.key, entry.value);
if (block.yield(context, newAssoc).isTrue())
return context.getRuntime().getTrue();
try {
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
IRubyObject newAssoc = RubyArray.newArray(context.runtime, entry.key, entry.value);
if (block.yield(context, newAssoc).isTrue())
return context.getRuntime().getTrue();
}
return context.getRuntime().getFalse();
} finally {
iteratorExit();
}
iteratorExit();

return context.getRuntime().getFalse();
}

private IRubyObject any_p_i_fast(ThreadContext context, Block block) {
iteratorEntry();
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
if (block.yieldSpecific(context, entry.key, entry.value).isTrue())
return context.getRuntime().getTrue();
try {
for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) {
if (block.yieldSpecific(context, entry.key, entry.value).isTrue())
return context.getRuntime().getTrue();
}
return context.getRuntime().getFalse();
} finally {
iteratorExit();
}
iteratorExit();

return context.getRuntime().getFalse();
}

/**