Skip to content

Commit

Permalink
Optimize hash lookup in Enumerable#group_by (#14235)
Browse files Browse the repository at this point in the history
Co-authored-by: Quinton Miller <[email protected]>
  • Loading branch information
straight-shoota and HertzDevil authored Jan 29, 2024
1 parent f6b8184 commit bc0c872
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/enumerable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,7 @@ module Enumerable(T)
h = Hash(U, Array(T)).new
each do |e|
v = yield e
if h.has_key?(v)
h[v].push(e)
else
h[v] = [e]
end
h.put_if_absent(v) { Array(T).new } << e
end
h
end
Expand Down

0 comments on commit bc0c872

Please sign in to comment.