mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 13:08:16 +01:00
Splice tree only when needed
This commit is contained in:
parent
6710ef4415
commit
49a315d22c
12
src/Tree.php
12
src/Tree.php
@ -2,9 +2,6 @@
|
||||
|
||||
namespace Cerbero\JsonParser;
|
||||
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* The JSON tree.
|
||||
*
|
||||
@ -94,9 +91,6 @@ final class Tree
|
||||
|
||||
$this->original[$this->depth] = $trimmedKey;
|
||||
$this->wildcarded[$this->depth] = $trimmedKey;
|
||||
|
||||
array_splice($this->original, $this->depth + 1);
|
||||
array_splice($this->wildcarded, $this->depth + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,8 +107,10 @@ final class Tree
|
||||
$this->original[$this->depth] = is_int($index) ? $index + 1 : 0;
|
||||
$this->wildcarded[$this->depth] = $referenceToken == '-' ? '-' : $this->original[$this->depth];
|
||||
|
||||
array_splice($this->original, $this->depth + 1);
|
||||
array_splice($this->wildcarded, $this->depth + 1);
|
||||
if (count($this->original) > $this->depth) {
|
||||
array_splice($this->original, $this->depth + 1);
|
||||
array_splice($this->wildcarded, $this->depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user