-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use frozen string literal for ruby 2.3.0+ #970
Conversation
def to_s(*args) | ||
location.to_s | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous whitespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change removes the superfluous whitespace that was in the file (my editor did that I guess) -- if you're saying the line is unneeded, it was there before but with some spaces at the beginning
Nice work, @twalpole! Good call including the pragma everywhere. Some of these cases suggest that methods are mutating strings that they probably shouldn't.
|
value.sub! FILENAME_RE, '\1="\2"' | ||
value.sub FILENAME_RE, '\1="\2"' | ||
else | ||
value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@jeremy Ok -I've swapped to dup in most places and also cleaned up the raise_error warnings to make sure they weren't hiding frozen string errors. |
@@ -71,6 +72,7 @@ def []=(name, value) | |||
|
|||
if hash[:body].respond_to? :force_encoding and hash[:body].respond_to? :valid_encoding? | |||
if not hash[:body].valid_encoding? and default_values[:content_transfer_encoding].downcase == "binary" | |||
hash[:body] = hash[:body].dup if hash[:body].frozen? | |||
hash[:body].force_encoding("BINARY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another spot to sidestep the frozen check:
hash[:body] = hash[:body].dup.force_encoding("BINARY")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in the gems code as opposed to test, and I figured the body could be large -- for performance and memory reasons I didn't want to dup it unless necessary
Looking good @twalpole! Would you squash down to a single commit? |
@jeremy done |
use frozen string literal for ruby 2.3.0+
Oh, that's great! I guess that fixes #965 except the method I mentioned there also uses |
@aried3r The one string |
No description provided.