Skip to content


Browse files Browse the repository at this point in the history
When comparing two Indexables (Indexable#==) it is safe to access
other's value through unsafe_at as its size has already been checked.
  • Loading branch information
karlseguin authored and asterite committed Feb 20, 2017
1 parent 2bc0030 commit 44c859f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/
Expand Up @@ -211,6 +211,15 @@ module Indexable(T)
size == 0

# Optimized version of `equals?` used when `other` is also an `Indexable`.
def equals?(other : Indexable)
return false if size != other.size
each_with_index do |item, i|
return false unless yield(item, other.unsafe_at(i))

# Determines if `self` equals *other* according to a comparison
# done by the given block.
Expand Down

0 comments on commit 44c859f

Please sign in to comment.