[wp-trac] [WordPress Trac] #50223: Performance improvement: Avoid using array_unique() where possible

WordPress Trac noreply at wordpress.org
Sat May 23 13:54:15 UTC 2020


#50223: Performance improvement: Avoid using array_unique() where possible
-------------------------------+------------------------------
 Reporter:  aristath           |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  lowest             |   Milestone:  Awaiting Review
Component:  General            |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  performance
-------------------------------+------------------------------

Comment (by SergeyBiryukov):

 I'm all for performance improvements, but if replacing `array_unique()`
 causes a noticeable difference somewhere in core, I'd rather see if the
 underlying logic could be improved.

 Unless using `array_unique()` is disallowed in WPCS (which is probably not
 a good idea), new instances will inevitably get added over time. Replacing
 some instances randomly would only cause inconsistencies and confusion,
 even with inline comments.

 > However, I don't think we should sacrifice readability for this. A flip-
 flip doesn't convey that the variable is transformed to yield unique keys;
 I, therefore, believe these ~~rudimentary~~ low-level issues should be
 forwarded to the PHP Group.

 This seems like a good idea, that way plugins, themes, and other plaforms
 would also benefit from any performance impovements to `array_unique()`.

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


More information about the wp-trac mailing list