mirror of
https://github.com/dg/dibi.git
synced 2025-08-19 12:21:46 +02:00
REGEXP optimizations
This commit is contained in:
@@ -107,7 +107,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
} else {
|
} else {
|
||||||
$sql[] = substr($arg, 0, $toSkip)
|
$sql[] = substr($arg, 0, $toSkip)
|
||||||
/*
|
/*
|
||||||
preg_replace_callback('/
|
. preg_replace_callback('/
|
||||||
(?=[`[\'":%?]) ## speed-up
|
(?=[`[\'":%?]) ## speed-up
|
||||||
(?:
|
(?:
|
||||||
`(.+?)`| ## 1) `identifier`
|
`(.+?)`| ## 1) `identifier`
|
||||||
@@ -115,8 +115,8 @@ final class DibiTranslator extends DibiObject
|
|||||||
(\')((?:\'\'|[^\'])*)\'| ## 3,4) 'string'
|
(\')((?:\'\'|[^\'])*)\'| ## 3,4) 'string'
|
||||||
(")((?:""|[^"])*)"| ## 5,6) "string"
|
(")((?:""|[^"])*)"| ## 5,6) "string"
|
||||||
(\'|")| ## 7) lone quote
|
(\'|")| ## 7) lone quote
|
||||||
:(\S*?:)([a-zA-Z0-9._]?)| ## 8,9) substitution
|
:(\S*?:)([a-zA-Z0-9._]?)| ## 8,9) :substitution:
|
||||||
%([a-zA-Z]{1,4})(?![a-zA-Z]) ## 10) modifier
|
%([a-zA-Z]{1,4})(?![a-zA-Z])|## 10) modifier
|
||||||
(\?) ## 11) placeholder
|
(\?) ## 11) placeholder
|
||||||
)/xs',
|
)/xs',
|
||||||
*/ // note: this can change $this->args & $this->cursor & ...
|
*/ // note: this can change $this->args & $this->cursor & ...
|
||||||
@@ -344,7 +344,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
case 'i': // signed int
|
case 'i': // signed int
|
||||||
case 'u': // unsigned int, ignored
|
case 'u': // unsigned int, ignored
|
||||||
// support for long numbers - keep them unchanged
|
// support for long numbers - keep them unchanged
|
||||||
if (is_string($value) && preg_match('#[+-]?\d+(e\d+)?$#A', $value)) {
|
if (is_string($value) && preg_match('#[+-]?\d++(e\d+)?$#A', $value)) {
|
||||||
return $value;
|
return $value;
|
||||||
} else {
|
} else {
|
||||||
return $value === NULL ? 'NULL' : (string) (int) ($value + 0);
|
return $value === NULL ? 'NULL' : (string) (int) ($value + 0);
|
||||||
@@ -568,7 +568,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
return '*';
|
return '*';
|
||||||
|
|
||||||
} elseif (strpos($value, ':') !== FALSE) { // provide substitution
|
} elseif (strpos($value, ':') !== FALSE) { // provide substitution
|
||||||
$value = preg_replace_callback('#:(.*):#U', array(__CLASS__, 'subCb'), $value);
|
$value = preg_replace_callback('#:([^:\s]*):#', array(__CLASS__, 'subCb'), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->driver->escape($value, dibi::IDENTIFIER);
|
return $this->driver->escape($value, dibi::IDENTIFIER);
|
||||||
|
Reference in New Issue
Block a user