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: a3a8783b5bb9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9a260de70867
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 17, 2015

  1. Copy the full SHA
    f73f4bb View commit details
  2. Copy the full SHA
    5525b4f View commit details
  3. Copy the full SHA
    9a260de View commit details
Original file line number Diff line number Diff line change
@@ -1019,9 +1019,6 @@ public Object abs(long n) {
@CoreMethod(names = "bit_length")
public abstract static class BitLengthNode extends CoreMethodArrayArgumentsNode {

private static final int INT_BITS = Integer.numberOfLeadingZeros(0);
private static final int LONG_BITS = Long.numberOfLeadingZeros(0);

public BitLengthNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -1032,7 +1029,7 @@ public int bitLength(int n) {
n = ~n;
}

return INT_BITS - Integer.numberOfLeadingZeros(n);
return Integer.SIZE - Integer.numberOfLeadingZeros(n);
}

@Specialization
@@ -1041,7 +1038,7 @@ public int bitLength(long n) {
n = ~n;
}

return LONG_BITS - Long.numberOfLeadingZeros(n);
return Long.SIZE - Long.numberOfLeadingZeros(n);
}

}
Original file line number Diff line number Diff line change
@@ -567,7 +567,7 @@ public DynamicObject eachPackedArray(VirtualFrame frame, DynamicObject hash, Dyn
}

if (n < Layouts.HASH.getSize(hash)) {
yield(frame, block, Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{PackedArrayStrategy.getKey(store, n), PackedArrayStrategy.getValue(store, n)}, 2));
yieldPair(frame, block, PackedArrayStrategy.getKey(store, n), PackedArrayStrategy.getValue(store, n));
}
}
} finally {
@@ -584,7 +584,7 @@ public DynamicObject eachBuckets(VirtualFrame frame, DynamicObject hash, Dynamic
assert HashOperations.verifyStore(getContext(), hash);

for (Map.Entry<Object, Object> keyValue : BucketsStrategy.iterableKeyValues(Layouts.HASH.getFirstInSequence(hash))) {
yield(frame, block, Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{keyValue.getKey(), keyValue.getValue()}, 2));
yieldPair(frame, block, keyValue.getKey(), keyValue.getValue());
}

return hash;
@@ -601,6 +601,10 @@ public Object each(VirtualFrame frame, DynamicObject hash, NotProvided block) {
return toEnumNode.call(frame, hash, "to_enum", null, getSymbol(method.getName()));
}

private Object yieldPair(VirtualFrame frame, DynamicObject block, Object key, Object value) {
return yield(frame, block, Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[] { key, value }, 2));
}

}

@CoreMethod(names = "empty?")
@@ -784,7 +788,7 @@ public DynamicObject mapPackedArray(VirtualFrame frame, DynamicObject hash, Dyna
if (n < length) {
final Object key = PackedArrayStrategy.getKey(store, n);
final Object value = PackedArrayStrategy.getValue(store, n);
resultStore = arrayBuilderNode.appendValue(resultStore, n, yield(frame, block, key, value));
resultStore = arrayBuilderNode.appendValue(resultStore, n, yieldPair(frame, block, key, value));
}
}
} finally {
@@ -808,7 +812,7 @@ public DynamicObject mapBuckets(VirtualFrame frame, DynamicObject hash, DynamicO

try {
for (Map.Entry<Object, Object> keyValue : BucketsStrategy.iterableKeyValues(Layouts.HASH.getFirstInSequence(hash))) {
arrayBuilderNode.appendValue(store, index, yield(frame, block, keyValue.getKey(), keyValue.getValue()));
arrayBuilderNode.appendValue(store, index, yieldPair(frame, block, keyValue.getKey(), keyValue.getValue()));
index++;
}
} finally {
@@ -820,6 +824,10 @@ public DynamicObject mapBuckets(VirtualFrame frame, DynamicObject hash, DynamicO
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), arrayBuilderNode.finish(store, length), length);
}

private Object yieldPair(VirtualFrame frame, DynamicObject block, Object key, Object value) {
return yield(frame, block, Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[] { key, value }, 2));
}

}

@ImportStatic(HashGuards.class)