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
Optimise various methods and conditions to use best
performing alternatives where possible. Roughly:
* Uses methods that do not copy memory, e.g. strncmp
as alternative for strpos matching beginning of string.
* Switches order of some conditions to put the cheapest
checks first in order.
* Checks input before calling trim() - despite the function
returning the same string as input, it still costs memory
and introduces unnecessary overhead.
* Extracts variables for repeated identical function calls.
* Uses negative substring offsets instead of strlen + substr.
* Replaces single-char substr usages with substring access.
thrownewParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
// if next line is less indented or equal, then it means that the current value is null
297
300
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
@@ -430,7 +433,8 @@ private function doParse(string $value, int $flags)
430
433
$value = '';
431
434
432
435
foreach ($this->linesas$line) {
433
-
if ('' !== ltrim($line) && '#' === ltrim($line)[0]) {
436
+
$trimmedLine = trim($line);
437
+
if ('#' === ($trimmedLine[0] ?? '')) {
434
438
continue;
435
439
}
436
440
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
@@ -442,22 +446,22 @@ private function doParse(string $value, int $flags)
442
446
thrownewParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
0 commit comments