minor #10323 [Yaml] Fixed minor performance related issues in Yaml\Inline. (sun)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #10323). Discussion ---------- [Yaml] Fixed minor performance related issues in Yaml\Inline. Follow-up to #10312 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- a36fef5 Follow-up to #10312: Fixed minor performance related issues in Yaml\Inline.
This commit is contained in:
commit
ca60916331
|
@ -220,7 +220,9 @@ class Inline
|
||||||
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
|
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $evaluate ? self::evaluateScalar($output) : $output;
|
if ($evaluate) {
|
||||||
|
$output = self::evaluateScalar($output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -388,9 +390,9 @@ class Inline
|
||||||
$scalar = trim($scalar);
|
$scalar = trim($scalar);
|
||||||
$scalarLower = strtolower($scalar);
|
$scalarLower = strtolower($scalar);
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case 'null' == $scalarLower:
|
case 'null' === $scalarLower:
|
||||||
case '' == $scalar:
|
case '' === $scalar:
|
||||||
case '~' == $scalar:
|
case '~' === $scalar:
|
||||||
return null;
|
return null;
|
||||||
case 'true' === $scalarLower:
|
case 'true' === $scalarLower:
|
||||||
return true;
|
return true;
|
||||||
|
@ -425,10 +427,10 @@ class Inline
|
||||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||||
case is_numeric($scalar):
|
case is_numeric($scalar):
|
||||||
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar);
|
||||||
case 0 == strcasecmp($scalar, '.inf'):
|
case '.inf' === $scalarLower:
|
||||||
case 0 == strcasecmp($scalar, '.NaN'):
|
case '.nan' === $scalarLower:
|
||||||
return -log(0);
|
return -log(0);
|
||||||
case 0 == strcasecmp($scalar, '-.inf'):
|
case '-.inf' === $scalarLower:
|
||||||
return log(0);
|
return log(0);
|
||||||
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
|
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
|
||||||
return floatval(str_replace(',', '', $scalar));
|
return floatval(str_replace(',', '', $scalar));
|
||||||
|
|
Reference in New Issue