From ec08174dd90637ddd6c2bc86a953ba3c08254ddd Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Wed, 15 Mar 2023 00:44:18 +0530 Subject: [PATCH] Use Enumerable#to_h to avoid extra allocation --- lib/ulid/constants.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ulid/constants.rb b/lib/ulid/constants.rb index 2a8eed5..9a4f41f 100644 --- a/lib/ulid/constants.rb +++ b/lib/ulid/constants.rb @@ -15,7 +15,7 @@ module Constants # Byte to index table for O(1) lookups when unmarshaling. # We rely on nil as sentinel value for invalid indexes. - B32REF = Hash[ ENCODING.split('').each_with_index.to_a ] + B32REF = ENCODING.split('').each_with_index.to_h end end