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

Remove unnecessary and expensive hasService check #36

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

tfrommen
Copy link
Member

@tfrommen tfrommen commented Jun 30, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

This PR removes the ContainerConfigurator::hasService check inside ContainerConfigurator::addService.

This is unnecessary and potentially expensive (especially with large and/or multiple and/or composite containers).

Previously, there was an exception thrown in case someone wanted to register a module with an existing ID. In 74cf1a5, the exception has been removed (for the reasons mentioned in #17).

This means, previously, we needed to know if there already is a service with the given ID. Now, we don't care, and we can simply unset the potentially-existing service as unset($foo) does not care whether $foo exists.

What is the current behavior? (You can also link to an open issue here)

Calling ContainerConfigurator::addService will internally call ContainerConfigurator::hasService.

What is the new behavior (if this is a feature change)?

Calling ContainerConfigurator::addService will attempt to unset the entry in the factory lookup table without checking if it exists first.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

@tfrommen tfrommen requested review from Chrico and Biont June 30, 2023 16:58
@Biont
Copy link
Member

Biont commented Jun 30, 2023

The explanation makes sense to me. LGTM, thanks

@tfrommen tfrommen merged commit 20f81d9 into master Jul 3, 2023
@tfrommen tfrommen deleted the remove-has-service-check branch July 3, 2023 15:52
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