Skip to content

Commit

Permalink
Block Parser: Explore a streaming lazy interface
Browse files Browse the repository at this point in the history
For a 3 MB document which took 5 seconds and 14 GB to parse, this version of the parser parsed it in 27 ms and 20 MB.
  • Loading branch information
dmsnell committed Jan 30, 2024
1 parent a172e31 commit a4f068d
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 319 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-block-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function offsetExists( $offset ) {
public function offsetGet( $offset ) {
$block = $this->blocks[ $offset ];

if ( isset( $block ) && is_array( $block ) ) {
if ( isset( $block ) && ( is_array( $block ) || $block instanceof WP_Parsed_Block ) ) {
$block = new WP_Block( $block, $this->available_context, $this->registry );

$this->blocks[ $offset ] = $block;
Expand Down
Loading

0 comments on commit a4f068d

Please sign in to comment.