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

Calling unsafe methods which don't return a string shouldn't fail #1750

Merged
merged 1 commit into from Jun 22, 2011
Merged

Calling unsafe methods which don't return a string shouldn't fail #1750

merged 1 commit into from Jun 22, 2011

Conversation

dmathieu
Copy link
Contributor

Unsafe methods are always calling #to_str when called so the object returned is a new string object.

If the original method doesn't return a string, like gsub with only one argument though, it'll fail as there's no to_str method.

@dmathieu
Copy link
Contributor Author

I have just changed my commit, to simplify the logic of the improvement.

@fxn
Copy link
Member

fxn commented Jun 19, 2011

send accepts strings, no need to create a symbol from them.

@dmathieu
Copy link
Contributor Author

Actually, as we're in a class_eval and the method name is a variable, I must either create a string or a symbol.
For micro-performances reasons, symbols are then better as it wouldn't create a new object instance if the same symbol has already been called.

@dmathieu
Copy link
Contributor Author

@fxn : what I mean is, anyway, we must either create a string or a symbol.
Creating a symbol avoids creating a new object every time the method is called.

@fxn
Copy link
Member

fxn commented Jun 22, 2011

Would it be better to interpolate unsafe_method as an ordinary method call?

@dmathieu
Copy link
Contributor Author

Oh ok, right, I definitely can do that.

@dmathieu
Copy link
Contributor Author

I have updated my commit.

@fxn
Copy link
Member

fxn commented Jun 22, 2011

Excellent, thank you :).

fxn added a commit that referenced this pull request Jun 22, 2011
Calling unsafe methods which don't return a string shouldn't fail
@fxn fxn merged commit 5654f68 into rails:master Jun 22, 2011
jake3030 pushed a commit to jake3030/rails that referenced this pull request Jun 28, 2011
…e:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
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.

None yet

2 participants