Skip to content

Commit

Permalink
[Truffle] Use do...end consistently for multiline blocks in core.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Dec 15, 2016
1 parent 3e7997f commit e750435
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions truffle/src/main/ruby/core/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,9 @@ def sample(count=undefined, options=undefined)

result = Array.new(self)

count.times { |i|
count.times do |i|
result.swap i, rng.rand(size)
}
end

return count == size ? result : result[0, count]
end
Expand Down Expand Up @@ -1517,21 +1517,21 @@ def uniq!(&block)
result = []
if block_given?
h = {}
each { |e|
each do |e|
v = yield(e)
unless h.key?(v)
h[v] = true
result << e
end
}
end
else
h = {}
each { |e|
each do |e|
unless h.key?(e)
h[e] = true
result << e
end
}
end
end
return if result.size == size

Expand Down
24 changes: 12 additions & 12 deletions truffle/src/main/ruby/core/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,18 @@ def zip(*lists)
index = 0
Lazy.new(self, enumerator_size) do |yielder, *args|
val = args.length >= 2 ? args : args.first
rests = lists.map { |list|
case list
when Array
list[index]
else
begin
list.next
rescue StopIteration
nil
end
end
}
rests = lists.map do |list|
case list
when Array
list[index]
else
begin
list.next
rescue StopIteration
nil
end
end
end
yielder.yield [val, *rests]
index += 1
end
Expand Down
8 changes: 4 additions & 4 deletions truffle/src/main/ruby/core/hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ def values_at(*args)

def invert
inverted = {}
each_pair { |key, value|
each_pair do |key, value|
inverted[value] = key
}
end
inverted
end

Expand All @@ -468,10 +468,10 @@ def to_hash

def to_proc
proc_hash = self
Proc.new { |*args|
Proc.new do |*args|
Rubinius::Type.check_arity(args.size, 1, 1)
proc_hash[args[0]]
}
end
end

# Implementation of a fundamental Rubinius method that allows their Hash
Expand Down
8 changes: 4 additions & 4 deletions truffle/src/main/ruby/core/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,20 @@ def self.setpriority(kind, id, priority)
def self.groups
g = []
count = Truffle::POSIX.getgroups(0, nil)
FFI::MemoryPointer.new(:int, count) { |p|
FFI::MemoryPointer.new(:int, count) do |p|
num_groups = Truffle::POSIX.getgroups(count, p)
Errno.handle if num_groups == -1
g = p.read_array_of_int(num_groups)
}
end
g
end

def self.groups=(g)
@maxgroups = g.length if g.length > @maxgroups
FFI::MemoryPointer.new(:int, @maxgroups) { |p|
FFI::MemoryPointer.new(:int, @maxgroups) do |p|
p.write_array_of_int(g)
Errno.handle if Truffle::POSIX.setgroups(g.length, p) == -1
}
end
g
end

Expand Down
4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ def rb_path2class(path)
end

def rb_proc_new(function, value)
proc { |*args|
Proc.new do |*args|
Truffle::Interop.execute(function, *args)
}
end
end

def verbose
Expand Down
4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/truffle/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def self.load_arguments_from_array_kw_helper(array, kwrest_name, binding)
def self.add_rejected_kwargs_to_rest(rest, kwargs)
return if kwargs.nil?

rejected = kwargs.select { |key, value|
rejected = kwargs.select do |key, value|
not key.is_a?(Symbol)
}
end

unless rejected.empty?
rest.push rejected
Expand Down

0 comments on commit e750435

Please sign in to comment.