Skip to content

Remove base64 dependency#2110

Merged
ioquatix merged 1 commit intorack:mainfrom
jeremyevans:unpack
Aug 15, 2023
Merged

Remove base64 dependency#2110
ioquatix merged 1 commit intorack:mainfrom
jeremyevans:unpack

Conversation

@jeremyevans
Copy link
Contributor

base64 will be removed from the default gems in Ruby 3.4. Switch to using String#unpack1 instead.

base64 will be removed from the default gems in Ruby 3.4. Switch
to using String#unpack1 instead.
@jeremyevans jeremyevans requested a review from ioquatix August 15, 2023 21:25
@ioquatix
Copy link
Member

Any performance implications?

@dentarg
Copy link
Contributor

dentarg commented Aug 15, 2023

Any performance implications?

Should be none? Maybe even faster? https://github.com/ruby/ruby/blob/efd611ceb661a230f121797079376cdb4e831951/lib/base64.rb#L61-L63

@ioquatix ioquatix merged commit 696ed9e into rack:main Aug 15, 2023
koic added a commit to koic/rubocop that referenced this pull request Oct 25, 2023
Fixes rubocop#12310.

This PR drops `base64` gem from runtime dependency.

RuboCop only uses `Base64.encode64` from the `base64` gem. Therefore, there's no need to depend on
the entire `base64` gem. The implementation of `Base64.encode64` is quite simple:
https://github.com/ruby/base64/blob/v0.1.1/lib/base64.rb#L27-L40

This change is a better approach that has also been adopted by rack/rack#2110.
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Oct 26, 2023
Fixes #12310.

This PR drops `base64` gem from runtime dependency.

RuboCop only uses `Base64.encode64` from the `base64` gem. Therefore, there's no need to depend on
the entire `base64` gem. The implementation of `Base64.encode64` is quite simple:
https://github.com/ruby/base64/blob/v0.1.1/lib/base64.rb#L27-L40

This change is a better approach that has also been adopted by rack/rack#2110.
@Nakilon
Copy link

Nakilon commented Dec 24, 2023

I wish this stdlib was less cryptic. Why m vs m0? Why unpack vs unpack1? When I need base64 it's 99% chance that I don't need any other pack/unpack formats and so I should not need to remember these magick symbols. Base64 was making it clearer.

ioquatix pushed a commit that referenced this pull request May 18, 2025
base64 will be removed from the default gems in Ruby 3.4. Switch
to using String#unpack1 instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants