From 5b8608657ff887288c7cbaf33a0659a8faecea70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 20 Jun 2016 18:20:57 +0200 Subject: [PATCH] Simplify finding largest table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We really do not need intermediate array for that. Signed-off-by: Michal Čihař --- libraries/DbQbe.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/DbQbe.php b/libraries/DbQbe.php index 6aeeee76ea..fdd785fd8a 100644 --- a/libraries/DbQbe.php +++ b/libraries/DbQbe.php @@ -1470,17 +1470,21 @@ class DbQbe // Of course we only want to check each table once $checked_tables = $candidate_columns; $tsize = array(); - $csize = array(); + $maxsize = -1; + $result = ''; foreach ($candidate_columns as $table) { if ($checked_tables[$table] != 1) { $_table = new Table($table, $this->_db); $tsize[$table] = $_table->countRecords(); $checked_tables[$table] = 1; } - $csize[$table] = $tsize[$table]; + if ($tsize[$table] > $maxsize) { + $maxsize = $tsize[$table]; + $result = $table; + } } // Return largest table - return array_search(max($csize), $csize); + return $result; } /**