Skip to content

Commit

Permalink
Showing 2 changed files with 1 addition and 33 deletions.
17 changes: 0 additions & 17 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -2115,23 +2115,6 @@ protected boolean isSmall(DynamicObject array) {

}

@CoreMethod(names = "unshift", rest = true, raiseIfFrozenSelf = true)
public abstract static class UnshiftNode extends CoreMethodArrayArgumentsNode {

@Specialization
public DynamicObject unshift(DynamicObject array, Object... args) {
CompilerDirectives.transferToInterpreter();

assert RubyGuards.isRubyArray(array);
final Object[] newStore = new Object[getSize(array) + args.length];
System.arraycopy(args, 0, newStore, 0, args.length);
ArrayUtils.copy(getStore(array), newStore, args.length, getSize(array));
setStoreAndSize(array, newStore, newStore.length);
return array;
}

}

@CoreMethod(names = "zip", rest = true, required = 1, needsBlock = true)
public abstract static class ZipNode extends ArrayCoreMethodNode {

17 changes: 1 addition & 16 deletions truffle/src/main/ruby/core/rubinius/common/array.rb
Original file line number Diff line number Diff line change
@@ -1848,23 +1848,8 @@ def uniq!(&block)
def unshift(*values)
Rubinius.check_frozen

return self if values.empty?
self[0, 0] = values

m = Rubinius::Mirror::Array.reflect values

if @start > values.size
# fit the new values in between 0 and @start if possible
@start -= values.size
@tuple.copy_from(m.tuple, 0, values.size, @start)
else
new_tuple = Rubinius::Tuple.new @total + values.size
new_tuple.copy_from m.tuple, 0, values.size, 0
new_tuple.copy_from @tuple, @start, @total, values.size
@start = 0
@tuple = new_tuple
end

@total += values.size
self
end

0 comments on commit 9176fc8

Please sign in to comment.