WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#31260 closed defect (bug) (fixed)

Replace array_shift() with current() in bundled themes

Reported by: SergeyBiryukov Owned by: 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 6 years ago.

Download all attachments as: .zip

Change History (5)

#2 @lancewillett
6 years ago

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

#3 @lancewillett
6 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
6 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.