Skip to content

Commit c3e9ace

Browse files
committed
Use Kernel#loop for infinite loops
1 parent dff1cf3 commit c3e9ace

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/immutable/list.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def select(&block)
268268
return enum_for(:select) unless block_given?
269269
LazyList.new do
270270
list = self
271-
while true
271+
loop do
272272
break list if list.empty?
273273
break Cons.new(list.head, list.tail.select(&block)) if yield(list.head)
274274
list = list.tail
@@ -895,7 +895,7 @@ def indices(object = Undefined, i = 0, &block)
895895
return EmptyList if empty?
896896
LazyList.new do
897897
node = self
898-
while true
898+
loop do
899899
break Cons.new(i, node.tail.indices(Undefined, i + 1, &block)) if yield(node.head)
900900
node = node.tail
901901
break EmptyList if node.empty?
@@ -1346,7 +1346,7 @@ def cached_size?
13461346
MUTEX = Mutex.new
13471347

13481348
def realize
1349-
while true
1349+
loop do
13501350
# try to "claim" the right to run the block which realizes target
13511351
if @atomic.compare_and_set(0,1) # full memory barrier here
13521352
begin
@@ -1455,7 +1455,7 @@ def realize
14551455
mutex = @mutex
14561456
mutex && mutex.synchronize do
14571457
return if @head != Undefined # another thread got ahead of us
1458-
while true
1458+
loop do
14591459
if !@buffer.empty?
14601460
@head = @buffer.shift
14611461
@tail = Partitioned.new(@partitioner, @buffer, @mutex)
@@ -1516,7 +1516,7 @@ def realize
15161516
mutex = @mutex
15171517
mutex && mutex.synchronize do
15181518
return if @head != Undefined # another thread got ahead of us
1519-
while true
1519+
loop do
15201520
if !@buffer.empty?
15211521
@head = @buffer.shift
15221522
@tail = Left.new(@splitter, @buffer, @mutex)

lib/immutable/sorted_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ def eql?(other)
948948
return false if not instance_of?(other.class)
949949
return false if size != other.size
950950
a, b = self.to_enum, other.to_enum
951-
while true
951+
loop do
952952
return false if !a.next.eql?(b.next)
953953
end
954954
rescue StopIteration

lib/immutable/vector.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,13 @@ def product(*vectors)
10841084
end
10851085

10861086
if block_given?
1087-
while true
1087+
loop do
10881088
yield build_array[]
10891089
return self if bump_counters[]
10901090
end
10911091
else
10921092
result = []
1093-
while true
1093+
loop do
10941094
result << build_array[]
10951095
return result if bump_counters[]
10961096
end

0 commit comments

Comments
 (0)