Skip to content

PERF: remove useless calls to count() in core classes, tpls and modulebuilder template #34376

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

Open
wants to merge 4 commits into
base: 18.0
Choose a base branch
from

Conversation

marc-dll
Copy link
Contributor

@marc-dll marc-dll commented Jun 8, 2025

PERF: remove useless calls to count() in core classes, tpls and modulebuilder template

Dolibarr is filled with calls to function count() whose result is simply compared to 0 (to see if the passed array is empty or not) or below a certain value. This loses a lot of time because under the hood, time is spent needlessly to really return the number of elements.

I searched for any call to count in main core Dolibarr classes, tpls, and in the modulebuilder template, and replaced those calls (mostly using empty() or replacing for with foreach) where necessary.

@eldy
Copy link
Member

eldy commented Jun 8, 2025

As this is refactoring, this must be pushed into develop branch.
Only bug fixes can be pushed in already released version.

@eldy eldy added the PR no feature/refacto into freezed/released branch PR can't be accepted because it's a feature change or refactoring pushed into a stable frozen branch label Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR no feature/refacto into freezed/released branch PR can't be accepted because it's a feature change or refactoring pushed into a stable frozen branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants