Skip to content

Update gem to support frozen string literal#337

Closed
maxwell wants to merge 2 commits into
twitter:masterfrom
maxwell:update-gem-to-support-frozen-string-literal
Closed

Update gem to support frozen string literal#337
maxwell wants to merge 2 commits into
twitter:masterfrom
maxwell:update-gem-to-support-frozen-string-literal

Conversation

@maxwell
Copy link
Copy Markdown

@maxwell maxwell commented Dec 13, 2020

Problem

As a user of the twitter-text gem, I want to turn on frozen_string_literal for my application, but the twitter-text gem does not support the setting, therefore I can not turn it on for my application.

see: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/
for more info.

Solution

  1. Add the magic comment to all .rb files
  2. Remove a couple of places we are using << operator on Strings
  3. Change the String monkey patch to not modify instance state.

Result
Running the tests as

RUBYOPT=--enable-frozen-string-literal rake  

are green.

1) Add magic comment to all rb files
2) Remove using << with strings to prevent modification
3) For the monkey patch to string, we can not set instance state in  the String classes, because Strings are now immutable.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 13, 2020

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants