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

Use + instead of dup to unfreeze a string #769

Merged
merged 1 commit into from
Oct 2, 2020
Merged

Use + instead of dup to unfreeze a string #769

merged 1 commit into from
Oct 2, 2020

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Oct 2, 2020

This is slightly faster than .dup

Signed-off-by: Tim Smith tsmith@chef.io

This is slightly faster than .dup

Signed-off-by: Tim Smith <tsmith@chef.io>
@tas50 tas50 requested review from a team as code owners October 2, 2020 04:40
@@ -78,7 +78,7 @@ def on_send(node)
else
"\"#{type.source}[\#{#{name.source}}]\""
end
new_val = "#{notify_type} #{action.source}, #{service_value}".dup
new_val = +"#{notify_type} #{action.source}, #{service_value}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this string frozen? I wouldn't expect a dynamically built string to be automatically frozen somehow..

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I just tried it out and it is. TIL.

@tas50 tas50 merged commit f0db70a into master Oct 2, 2020
@tas50 tas50 deleted the speedup_dup branch October 2, 2020 16:35
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.

2 participants