Opened 2 years ago
Closed 2 years ago
#17110 closed defect (bug) (fixed)
apply_filters() performance
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.2 |
| Component: | Performance | Version: | 3.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | ocean90 |
Description
Pushing and popping to the wp_current_filter array is not necessary if there is not a function hooked to the filter.
Attachments (2)
Change History (9)
comment:3
andrewryno
— 2 years ago
Above my head to do it myself, but since apply_filters_ref_array() is almost identical, could this patch be used in that function as well (but slightly modified if needed)?
comment:5
ryan
— 2 years ago
On a front page load with 5 posts and default theme, that reduces the number of array_pop() calls from 3272 to 250.
Note: See
TracTickets for help on using
tickets.
On my test setup, that patch eliminates 2886 calls to array_pop() as well as the corresponding assignments and reduces time spent in apply_filters() by almost 50%. Most filters, like the often called gettext one, have nothing hooked to them so the pushing and popping is a waste of time. For cases where there is hook on the filter, the patch adds one isset check.