From 7c7fc037cbc92434f793b5342a81533bee638503 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Wed, 4 Oct 2023 14:47:50 +0700 Subject: [PATCH] Improve performance of quoting column names up to 10% using `array_map()` --- src/DMLQueryBuilder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index 4639d12..6b3a82a 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -15,6 +15,7 @@ use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder; +use function array_map; use function implode; use function count; @@ -67,9 +68,10 @@ public function batchInsert(string $table, array $columns, iterable|Generator $r return ''; } - foreach ($columns as $i => $name) { - $columns[$i] = $this->quoter->quoteColumnName($name); - } + $columns = array_map( + [$this->quoter, 'quoteColumnName'], + $columns, + ); $tableAndColumns = ' INTO ' . $this->quoter->quoteTableName($table) . ' (' . implode(', ', $columns) . ') VALUES ';