Commit 1dba087
committed
Return fragment results as children arrays, skip the intermediate node
Multi-branch fragment rules can't be expanded at grammar build time, but
their runtime role is still trivial: match a sequence of symbols and have
the caller splice the resulting children into its own node. The old code
allocated a full WP_Parser_Node for each fragment match just to have the
caller immediately copy its children out.
Return the children array directly from fragments instead. The caller
distinguishes via is_array($subnode) and splices in-place, saving a
Parser_Node allocation per fragment match (~253k per 10k queries).
End-to-end parser benchmark:
Before: ~27,000 QPS (avg) After: ~28,700 QPS (+6%).1 parent 6c9b869 commit 1dba087
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | | - | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
0 commit comments