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

Optimize performance by using isset() instead of in_array() #24677

Merged
merged 2 commits into from
Oct 22, 2019
Merged

Optimize performance by using isset() instead of in_array() #24677

merged 2 commits into from
Oct 22, 2019

Conversation

andrey-legayev
Copy link
Contributor

@andrey-legayev andrey-legayev commented Sep 20, 2019

Description (*)

I've run XDebug profiler to see why static content deploy takes so much time.
Many calls of in_array() grabbed my attention and I've fixed two such places:

  1. lib/internal/Magento/Framework/Module/ModuleList/Loader.php
  2. lib/internal/Magento/Framework/Setup/Lists.php

Fixed Issues (if relevant)

N/A

Manual testing scenarios (*)

General regression testing.

Questions or comments

N/A

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Sep 20, 2019

Hi @andrey-legayev. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@andrey-legayev
Copy link
Contributor Author

I need a help with following code issue:

FILE: ...html/lib/internal/Magento/Framework/Module/ModuleList/Loader.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 203 | WARNING | Direct throw of generic Exception is discouraged.
     |         | Use context specific instead.

@ihor-sviziev do you have an idea which exception should be thrown instead of \Exception ?

@ihor-sviziev ihor-sviziev self-assigned this Sep 20, 2019
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

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

Hi @andrey-legayev,
I think \Exception there could be replaced to \LogicException

@ihor-sviziev ihor-sviziev added Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Cleanup labels Sep 21, 2019
@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-5923 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

andrey-legayev and others added 2 commits October 9, 2019 17:37
I've run XDebug profiler to see why static content deploy takes so much
time. Many in_array() calls grabbed my attention and I've fixed it.

Co-Authored-By: Ihor Sviziev <ihor-sviziev@users.noreply.github.com>
@andrey-legayev
Copy link
Contributor Author

Updates:

  • fixed merge conflict
  • replaced one more in_array inside loop by isset()

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-5923 has been created to process this Pull Request

@engcom-Bravo engcom-Bravo self-assigned this Oct 9, 2019
@engcom-Bravo
Copy link
Contributor

✔️ QA passed

@magento-engcom-team magento-engcom-team merged commit d875236 into magento:2.3-develop Oct 22, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 22, 2019

Hi @andrey-legayev, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.4 milestone Oct 22, 2019
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.

5 participants