Skip to content

Commit 26a1b1c

Browse files
committed
doc
1 parent 92802e9 commit 26a1b1c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

autoresearch.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Optimize `WP_HTML_Processor::next_token()` tokenization throughput on html-stand
5959

6060
10. **Use int bookmark names** — Avoid int-to-string conversion per token by passing counter directly. ~14ms.
6161

62-
### Current: 1925ms mean (stddev 30ms) — 21.5% improvement
62+
### Current: 1830ms mean (stddev 40ms) — 25.4% improvement
6363

6464
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.
6565

@@ -75,6 +75,12 @@ Optimize `WP_HTML_Processor::next_token()` tokenization throughput on html-stand
7575

7676
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.
7777

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+
7884
### Dead Ends
7985

8086
- **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
104110
- **Combined token+event object** — merge WP_HTML_Token and WP_HTML_Stack_Event to reduce allocations
105111
- **Pre-scanned tag name table** — for known HTML elements, use a lookup instead of substr+strtoupper
106112
- **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

Comments
 (0)