1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Prefer String#ljust over String#<< for padding

This commit is contained in:
lsylvester 2018-10-17 10:48:11 -05:00 committed by schneems
parent 2f99da00c7
commit 73f9cd2da4

View file

@ -193,9 +193,8 @@ module ActiveRecord
# to account for this we pad the output with zeros
def raw_timestamp_to_cache_version(timestamp)
key = timestamp.delete("- :.")
padding = 20 - key.length
if padding != 0
key << "0" * padding
if key.length < 20
key.ljust(20, "0")
else
key
end