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
improved sql comment handling #73
Conversation
|
Please note that the tests are currently not passing when run on travis (https://travis-ci.org/travis-ci/marginalia/jobs/431465306). Possibly due to the dependency on the old It also looks like the tests haven't been enabled for a while now though. So fixing that seems out of scope for this patch. I was able to successfully run the tests locally via: |
lib/marginalia/comment.rb
Outdated
| ret | ||
| end | ||
|
|
||
| def self.escape_sql_comment(str) | ||
| str = str.dup |
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.
Can't we only dup if the str includes the patterns bellow? I want to save the extra allocation if not needed.
|
I've made the dup conditional. In fact I'm not sure if it is even needed. Since the |
lib/marginalia/comment.rb
Outdated
| def self.escape_sql_comment(str) | ||
| if str.include?('/*') || str.include?('*/') | ||
| str = str.dup | ||
| 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.
You are right, we don't need the dup. gsub should already create a new string for us.
|
Removed the |
|
Thanks. i am cleaning up test and releasing a new gem version |
This is an improved version of #56.