Skip to content

Conversation

@yogeshsuhagiya
Copy link
Member

Count the size of array outside for loop and passed the result to for loop.

Fixed Issues (if relevant)

N/A

Manual testing scenarios

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 on Travis CI are green)

@miguelbalparda
Copy link
Contributor

Hi @yogeshks! I checked the code and it seems to be a minor fix to improve readability. Is this correct or I'm missing something else?

@miguelbalparda miguelbalparda self-assigned this Mar 13, 2018
@miguelbalparda miguelbalparda removed the request for review from davidalger March 13, 2018 12:14
@orlangur
Copy link
Contributor

Hi @yogeshks, according to https://stackoverflow.com/questions/4566314/php-what-is-the-complexity-i-e-o1-on-of-the-function-count such optimization seems to be irrelevant in PHP world.

@yogeshsuhagiya
Copy link
Member Author

yogeshsuhagiya commented Mar 13, 2018

Hi @miguelbalparda,
You're right, it just a minor fix.

@yogeshsuhagiya
Copy link
Member Author

Hi @orlangur

I've reviewed your referral link and I agree with you but isn't it best practice to use function outside loops?

@orlangur
Copy link
Contributor

@yogeshks,

isn't it best practice to use function outside loops?

No, it is only relevant in case we have some heavy operation, like O(N) counting of array elements, some invariant strpos etc.

Thanks for quick response and collaboration!

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