Opened 14 years ago
Closed 14 years ago
#17110 closed defect (bug) (fixed)
apply_filters() performance
Reported by: | ryan | Owned by: | |
---|---|---|---|
Milestone: | 3.2 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Performance | Keywords: | has-patch |
Focuses: | Cc: |
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)
#3
@
14 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)?
#5
@
14 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.