improve grammar performance

This commit is contained in:
Dennis Eichhorn 2023-10-04 23:57:10 +00:00
parent 6dcb540248
commit febcc20001

View File

@ -226,16 +226,16 @@ abstract class GrammarAbstract
$identifierStart = $this->systemIdentifierStart; $identifierStart = $this->systemIdentifierStart;
$identifierEnd = $this->systemIdentifierEnd; $identifierEnd = $this->systemIdentifierEnd;
if (\stripos($system, '(') !== false) { // @todo: maybe the if/elseif has to get swapped in order. There could be a count(table.name) for example
$identifierStart = ''; if ((\stripos($system, '.')) !== false) {
$identifierEnd = ''; // The following code could have been handled with \explode more elegantly but \explode needs more memory and more time
} // Normally this wouldn't be a problem but in this case there are so many function calls to this routine,
// that it makes sense to make this "minor" improvement.
// The following code could have been handled with \explode more elegantly but \explode needs more memory and more time // This is actually slower than \explode(), despite knowing the first index
// Normally this wouldn't be a problem but in this case there are so many function calls to this routine, //$split = [\substr($system, 0, $pos), \substr($system, $pos + 1)];
// that it makes sense to make this "minor" improvement.
if (($pos = \stripos($system, '.')) !== false) { $split = \explode('.', $system);
$split = [\substr($system, 0, $pos), \substr($system, $pos + 1)];
$identifierTwoStart = $identifierStart; $identifierTwoStart = $identifierStart;
$identifierTwoEnd = $identifierEnd; $identifierTwoEnd = $identifierEnd;
@ -248,9 +248,10 @@ abstract class GrammarAbstract
return $identifierStart . $split[0] . $identifierEnd return $identifierStart . $split[0] . $identifierEnd
. '.' . '.'
. $identifierTwoStart . $split[1] . $identifierTwoEnd; . $identifierTwoStart . $split[1] . $identifierTwoEnd;
} } elseif ($system === '*'
|| \stripos($system, '(') !== false
if ($system === '*') { || \is_numeric($system)
) {
$identifierStart = ''; $identifierStart = '';
$identifierEnd = ''; $identifierEnd = '';
} }