зеркало из https://github.com/github/ruby.git
base64.rb: improve performance of Base64.urlsafe_encode64
* lib/base64.rb: avoid unnecessary memory allocations
This commit is contained in:
Родитель
3ca3c8d768
Коммит
1bdabaa6b1
|
@ -81,8 +81,9 @@ module Base64
|
|||
# Note that the result can still contain '='.
|
||||
# You can remove the padding by setting +padding+ as false.
|
||||
def urlsafe_encode64(bin, padding: true)
|
||||
str = strict_encode64(bin).tr("+/", "-_")
|
||||
str = str.delete("=") unless padding
|
||||
str = strict_encode64(bin)
|
||||
str.tr!("+/", "-_")
|
||||
str.delete!("=") unless padding
|
||||
str
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче