Skip to content

perf: Remove useless uses of array_shift - #64310

Merged
come-nc merged 1 commit into
masterfrom
perf/avoid-array-shift
Sep 17, 2026
Merged

come-nc merged 1 commit into
masterfrom
perf/avoid-array-shift

Conversation

@come-nc

@come-nc come-nc commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Calling array_shift in a loop is expensive for nothing, foreach is enough.
This is not a huge difference but can still be seen when looking at profiles and it happens in all requests.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@come-nc come-nc added this to the Nextcloud 36 milestone Sep 14, 2026
@come-nc come-nc self-assigned this Sep 14, 2026
@come-nc
come-nc added this pull request to stack #64192 September 14, 2026 13:42
@solracsf

Copy link
Copy Markdown
Member

The new code clears the queue after iteration. If a registration is added during iteration, it may be silently discarded (I've not verified this).

@come-nc
come-nc force-pushed the perf/avoid-array-shift branch from fac6211 to 3a4da18 Compare September 14, 2026 15:39
Base automatically changed from perf/short-circuit-aliases to master September 15, 2026 08:48
Calling array_shift in a loop is expensive for nothing, foreach is
 enough.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc force-pushed the perf/avoid-array-shift branch from 3a4da18 to 731543c Compare September 15, 2026 08:48
@come-nc

come-nc commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

The new code clears the queue after iteration. If a registration is added during iteration, it may be silently discarded (I've not verified this).

Registrations are only supported in the register method of applications, and these delegate methods run afterward.

@come-nc
come-nc marked this pull request as ready for review September 15, 2026 08:50
@come-nc
come-nc requested a review from a team as a code owner September 15, 2026 08:50
@come-nc
come-nc requested review from Altahrim, CarlSchwan, icewind1991 and leftybournes and removed request for a team September 15, 2026 08:50
@come-nc come-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 15, 2026
@come-nc
come-nc merged commit ea586dd into master Sep 17, 2026
163 of 169 checks passed
@come-nc
come-nc deleted the perf/avoid-array-shift branch September 17, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants