Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#31260 closed defect (bug) (fixed)

Replace array_shift() with current() in bundled themes

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: lancewillett's profile lancewillett
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch
Focuses: performance Cc:

Description

Background: #31182

array_shift() recalculates array indexes, and can be slow on large arrays. Most of the time, this is unnecessary, as we only use it to get the first element of the array, and the array is never used later.

Attachments (1)

31260.patch (2.9 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (5)

#2 @lancewillett
10 years ago

Nice improvement. current() is new to me, glad to know about it.

#3 @lancewillett
10 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In 31453:

Bundled themes: replace array_shift() with current() for performance.

Props SergeyBiryukov, fixes #31260.

#4 @SergeyBiryukov
9 years ago

In 31842:

Bundled themes: After [31453], replace current() with reset(), which is guaranteed to be the first item.

see #31259, #31260.

Note: See TracTickets for help on using tickets.