Skip to content

[Translation] small performance improvement for MessageCatalogue::replace #11708

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

Closed
wants to merge 1 commit into from

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Aug 19, 2014

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR

Saving an isset and array_replace call

@stof
Copy link
Member

stof commented Aug 19, 2014

👍 (even if it is clearly a micro-optimization)

@Tobion
Copy link
Contributor Author

Tobion commented Aug 23, 2014

ping @nicolas-grekas

@nicolas-grekas
Copy link
Member

👍

@nicolas-grekas
Copy link
Member

Wait: is there a possibility that someone has has specialized the add() method?
Because then this patch is going to change the behavior. As it's for 2.3, we should be cautious.

@Tobion
Copy link
Contributor Author

Tobion commented Aug 25, 2014

It's not part of our BC promise.

@fabpot
Copy link
Member

fabpot commented Aug 26, 2014

Even if it's not on our BC promise, this is clearly a behavior change and as such it cannot be committed in 2.3, but only master.

@Tobion
Copy link
Contributor Author

Tobion commented Aug 30, 2014

I'm fine if it only goes into master.

@fabpot
Copy link
Member

fabpot commented Aug 31, 2014

Thinking about it more, I think this should not be changed. If someone wants to alter the behavior of add(), he would now also have to override the replace() method and that does not sounds right. Given that we are not talking about a big improvement, I'm 👎 to make this change.

@Tobion
Copy link
Contributor Author

Tobion commented Aug 31, 2014

The internal implementation should never be relied on (if not explicitly defined for being extendable, like protected methods). So in this case if a user wants to change the behavior, he has to overwrite all public methods that are relevant, i.e. add and replace.

@Tobion
Copy link
Contributor Author

Tobion commented Aug 31, 2014

I bet we have dozens of classes where replace()/set() does not call add().
Or even in this class, get could also call has, but it doesn't. So if someone overwrites has it won't have an effect on get.

@fabpot
Copy link
Member

fabpot commented Sep 15, 2014

Closing as it can break some code for no real benefit.

@fabpot fabpot closed this Sep 15, 2014
@Tobion
Copy link
Contributor Author

Tobion commented Nov 5, 2015

Btw, the constructor doesn't call set or add as well. So the argument that it allows people to overwrite the behavior with one method is not correct.

@Tobion Tobion reopened this Nov 5, 2015
@nicolas-grekas
Copy link
Member

I suggest to close this one, the potential benefit looks micro, and we also have a potential bc break, let's stay on the safe side

@Tobion
Copy link
Contributor Author

Tobion commented Nov 24, 2015

Cmon if we go this route then we would need to rewrite almost all classes in symfony to use the available getters instead of accessing private properties. We never do that.
The BC break is so unlikely and even if somebody is affected it's clearly his faulty implementation relying on implementation details. Let's at least do this change in 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants