From 04e63740ab1a3781230fee65a0f42256ad2937cd Mon Sep 17 00:00:00 2001 From: Tigrov Date: Wed, 4 Oct 2023 14:30:56 +0700 Subject: [PATCH] Improve performance of quoting column names up to 10% using `array_map()` --- src/DMLQueryBuilder.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index 5e9ba4e69..9bfe7362f 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -9,6 +9,7 @@ use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder; +use function array_map; use function implode; /** @@ -22,11 +23,12 @@ public function insertWithReturningPks(string $table, QueryInterface|array $colu $returnColumns = $this->schema->getTableSchema($table)?->getPrimaryKey(); if (!empty($returnColumns)) { - $returning = []; - foreach ($returnColumns as $name) { - $returning[] = $this->quoter->quoteColumnName($name); - } - $sql .= ' RETURNING ' . implode(', ', $returning); + $returnColumns = array_map( + [$this->quoter, 'quoteColumnName'], + $returnColumns, + ); + + $sql .= ' RETURNING ' . implode(', ', $returnColumns); } return $sql;