From 582c6e1330cf235ef002bc3e2249470d40cae736 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 7 Feb 2026 15:03:12 +0700 Subject: [PATCH 1/3] Improve performance of `SqlParser::getNextPlaceholder()` method --- src/SqlParser.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/SqlParser.php b/src/SqlParser.php index 8bc311493..56ff835f4 100644 --- a/src/SqlParser.php +++ b/src/SqlParser.php @@ -8,6 +8,9 @@ final class SqlParser extends AbstractSqlParser { + /** @var string Identifier symbols, equals to `[$\w]` in regular expressions */ + private const IDENTIFIER_CHARS = '$' . self::WORD_CHARS; + public function getNextPlaceholder(?int &$position = null): ?string { $result = null; @@ -71,17 +74,7 @@ private function skipQuotedWithDollar(): void */ private function skipIdentifier(): void { - $continue = true; - - while ($continue && $this->position < $this->length) { - match ($this->sql[$this->position]) { - '$', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', - 'v', 'w', 'x', 'y', 'z', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', - 'V', 'W', 'X', 'Y', 'Z' => ++$this->position, - default => $continue = false, - }; - } + $length = strspn($this->sql, self::IDENTIFIER_CHARS, $this->position); + $this->position += $length; } } From c77e5f62749db1353bfb68259b4e55f59e604806 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 7 Feb 2026 15:49:28 +0700 Subject: [PATCH 2/3] Update doc --- src/SqlParser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SqlParser.php b/src/SqlParser.php index 56ff835f4..79eab4a5c 100644 --- a/src/SqlParser.php +++ b/src/SqlParser.php @@ -8,7 +8,7 @@ final class SqlParser extends AbstractSqlParser { - /** @var string Identifier symbols, equals to `[$\w]` in regular expressions */ + /** @var string Identifier characters, equivalent to `[$\w]` in regular expressions */ private const IDENTIFIER_CHARS = '$' . self::WORD_CHARS; public function getNextPlaceholder(?int &$position = null): ?string @@ -70,7 +70,7 @@ private function skipQuotedWithDollar(): void } /** - * Skips an identifier. Equals to `[$\w]+` in regular expressions. + * Skips an identifier. Equivalent to `[$\w]*` in regular expressions. */ private function skipIdentifier(): void { From 6279b8549588f9c5a520b8f054cd517acb1a21a3 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 7 Feb 2026 16:11:12 +0700 Subject: [PATCH 3/3] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0961bd27..2ccb009bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.0.2 under development -- no changes in this release. +- Enh #482: Improve performance of `SqlParser::getNextPlaceholder()` method (@Tigrov) ## 2.0.1 February 07, 2026