You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: autoresearch.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ Optimize `WP_HTML_Processor::next_token()` tokenization throughput on html-stand
59
59
60
60
10.**Use int bookmark names** — Avoid int-to-string conversion per token by passing counter directly. ~14ms.
61
61
62
-
### Current: 1925ms mean (stddev 30ms) — 21.5% improvement
62
+
### Current: 1830ms mean (stddev 40ms) — 25.4% improvement
63
63
64
64
11.**Optimize tag name parsing with direct char check + single strcspn** — Replace `strspn()` + `strcspn()` combo for tag name detection with direct character range comparison. Move bounds check before character access. ~50ms.
65
65
@@ -75,6 +75,12 @@ Optimize `WP_HTML_Processor::next_token()` tokenization throughput on html-stand
75
75
76
76
17.**Inline get_token_name() for tags and text in step()** — Fast-path matched tags (call get_tag() directly) and text nodes (return '#text' immediately), avoiding method call + switch dispatch. ~40ms.
77
77
78
+
18.**Cache current_node on open elements stack** — Maintain a cached reference updated on push/pop/remove_node. Avoids calling `end()` on every `current_node()` access. ~40ms.
79
+
80
+
19.**Optimize push/pop handlers with parent::is_tag_closer()** — Use `parent::is_tag_closer()` instead of `$this->is_tag_closer()` to skip is_virtual() dispatch chain. Cache current_token in local variable. ~50ms.
81
+
82
+
20.**Skip change_parsing_namespace() for HTML-namespace tokens** — Avoid calling the method when the namespace is already 'html'. Marginal.
83
+
78
84
### Dead Ends
79
85
80
86
-**Inline `skip_whitespace()`** — No improvement; PHP optimizes short function calls well.
@@ -104,4 +110,5 @@ Optimize `WP_HTML_Processor::next_token()` tokenization throughput on html-stand
104
110
-**Combined token+event object** — merge WP_HTML_Token and WP_HTML_Stack_Event to reduce allocations
105
111
-**Pre-scanned tag name table** — for known HTML elements, use a lookup instead of substr+strtoupper
106
112
-**Avoid WP_HTML_Token allocation for reprocessed tokens** — skip constructor when reprocessing same token
107
-
-**Cache current_node() result** — avoid calling end($this->stack) multiple times per step
113
+
-**Eliminate WP_HTML_Stack_Event allocation** — use parallel arrays instead of objects for event queue
114
+
-**Skip text node stack operations** — text nodes are always immediately popped; could avoid push/pop entirely
0 commit comments