Skip to content
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

update for frozen string literals #1101

Closed
wants to merge 1 commit into from

Conversation

twalpole
Copy link

@twalpole twalpole commented Mar 6, 2016

Frozen string literals - magic comment in all files and changes for tests to pass

@kgrz
Copy link
Member

kgrz commented Mar 7, 2016

...for tests to pass

Are these test related to the Sinatra repo? any situation where the failure can be reproduced? The master branch looks green.

@twalpole
Copy link
Author

twalpole commented Mar 7, 2016

Yes, it was Sinatra tests that were failing when using default frozen string literals - specifically attempting to concat to frozen strings, see the changes in base.rb. They don't fail in master because it's not defaulting to frozen string literals.

@@ -1,3 +1,4 @@
# frozen_string_literal: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed for the one string allocated here "sinatra/main" is an acceptable allocation that I doubt will be repeated enough to affect performance

@zzak
Copy link
Member

zzak commented Apr 13, 2016

I also don't want to litter the test files with this comment, as it's only necessary for runtime performance

@@ -842,6 +842,7 @@ def compile_template(engine, data, options, views)
body, path, line = settings.templates[data]
if body
body = body.call if body.respond_to?(:call)
body = body.dup if body.frozen?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a case where body is actually immutable from here? Maybe an empty request?

@zzak zzak added the feedback label Apr 13, 2016
@namusyaka namusyaka added this to the v2.1.0 milestone Feb 19, 2018
@chanks
Copy link
Contributor

chanks commented Mar 1, 2018

It'd be nice if frozen string literals were supported in rack-protection as well. I could open a separate PR for that if it'd be helpful.

@twalpole twalpole closed this Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants