Skip to content

Commit

Permalink
Micro-optimization
Browse files Browse the repository at this point in the history
strtr() is faster for single-character replacements.
  • Loading branch information
vlakoff committed Oct 27, 2021
1 parent 8bbb0ea commit 7880563
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type

if ($v instanceof Closure) {
$builder = $this->cleanClone();
$v = ' (' . str_replace("\n", ' ', $v($builder)->getCompiledSelect()) . ')';
$v = ' (' . strtr($v($builder)->getCompiledSelect(), "\n", ' ') . ')';
} else {
$bind = $this->setBind($k, $v, $escape);
$v = " :{$bind}:";
Expand Down Expand Up @@ -842,7 +842,7 @@ protected function _whereIn(?string $key = null, $values = null, bool $not = fal

if ($values instanceof Closure) {
$builder = $this->cleanClone();
$ok = str_replace("\n", ' ', $values($builder)->getCompiledSelect());
$ok = strtr($values($builder)->getCompiledSelect(), "\n", ' ');
} else {
$whereIn = array_values($values);
$ok = $this->setBind($ok, $whereIn, $escape);
Expand Down

0 comments on commit 7880563

Please sign in to comment.