[wp-trac] [WordPress Trac] #31259: Replace array_shift() with current() where appropriate

WordPress Trac noreply at wordpress.org
Sat Mar 7 22:55:14 UTC 2015


#31259: Replace array_shift() with current() where appropriate
-------------------------------------+--------------------------
 Reporter:  SergeyBiryukov           |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.2
Component:  General                  |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  performance
-------------------------------------+--------------------------

Comment (by wonderboymusic):

 Yes, `array_shift()` does a lot:
 https://github.com/php/php-
 src/blob/745504ea2a7066588af9714f5e32523a3fff4db7/ext/standard/array.c#L2199

 I tend to prefer `reset()` or `current()`, because `reset()` is guaranteed
 to be the first item, while `current()` is based on the pointer at
 calltime. Internally, they are basically the same.

 `reset()`
 https://github.com/php/php-
 src/blob/745504ea2a7066588af9714f5e32523a3fff4db7/ext/standard/array.c#L889

 `current()`
 https://github.com/php/php-
 src/blob/745504ea2a7066588af9714f5e32523a3fff4db7/ext/standard/array.c#L922

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31259#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list