ruby-changes:59151
From: Konstantin <ko1@a...>
Date: Tue, 10 Dec 2019 14:33:33 +0900 (JST)
Subject: [ruby-changes:59151] 1bdabaa6b1 (master): base64.rb: improve performance of Base64.urlsafe_encode64
https://git.ruby-lang.org/ruby.git/commit/?id=1bdabaa6b1 From 1bdabaa6b13344c195698ca5b0ced323cb93e2e1 Mon Sep 17 00:00:00 2001 From: Konstantin Papkovskiy <konstantin@p...> Date: Tue, 15 Aug 2017 17:35:58 +0300 Subject: base64.rb: improve performance of Base64.urlsafe_encode64 * lib/base64.rb: avoid unnecessary memory allocations diff --git a/lib/base64.rb b/lib/base64.rb index 24f0b02..5c8df84 100644 --- a/lib/base64.rb +++ b/lib/base64.rb @@ -81,8 +81,9 @@ module Base64 https://github.com/ruby/ruby/blob/trunk/lib/base64.rb#L81 # 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/