WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6796 closed enhancement (fixed)

Convert Walker classes to pass $output as reference

Reported by: mdawaffe Owned by:
Milestone: 2.5.1 Priority: normal
Severity: normal Version: 2.5
Component: General Keywords:
Focuses: Cc:

Description

The Walker classes pass the $output variable back and forth between their methods many many times, each time making the variable bigger and bigger. For walkable data with many items, this means the classes are copying very large variables many many times.

Converting the Walkers to pass $output by reference gives us a modest speed increase.

On a site with ~3200 categories (yes, that's a lot), the attached patch gave me ~35% decrease in the time it took Walker::walk() to output the $output created by Walker_Category_Checklist.

Note that any speed boost will only be significant in very large lists. Only then is $output copied many times and only then is $output very large.

Attached passes $output by reference in Walker and all core inheriting classes. Depending on how they are written, most Walker classes from plugins will work fine with these core modifications (but will not get the speed boost).

2.5.1?

Attachments (1)

6796.diff (8.9 KB) - added by mdawaffe 7 years ago.

Download all attachments as: .zip

Change History (4)

@mdawaffe7 years ago

comment:1 @ryan7 years ago

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

(In [7761]) Convert Walker classes to pass as reference. Props mdawaffe. fixes #6796 for trunk

comment:2 @ryan7 years ago

  • Milestone changed from 2.6 to 2.5.1

Nominating for 2.5 pending further testing on trunk.

comment:3 @ryan7 years ago

(In [7770]) Convert Walker classes to pass as reference. Props mdawaffe. fixes #6796 for 2.5

Note: See TracTickets for help on using tickets.