]> git.joonet.de Git - adminer.git/commitdiff
Avoid big ternary (save memory)
authorJakub Vrana <jakub@vrana.cz>
Tue, 22 Mar 2011 14:12:38 +0000 (15:12 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 22 Mar 2011 14:12:38 +0000 (15:12 +0100)
adminer/include/adminer.inc.php

index 449bdc127b97e9c7f968c9847cd619fbb9080c39..0a3ae17d5c6a571fbbed324dd5cec5f1db820c5c 100644 (file)
@@ -408,10 +408,10 @@ username.form['driver'].onchange();
                restart_session();
                $id = "sql-" . ($count++);
                $history = &get_session("queries");
-               $history[$_GET["db"]][] = (strlen($query) > 1e6 // not DB - reset in drop database
-                       ? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
-                       : $query
-               ); //! respect $_GET["ns"]
+               if (strlen($query) > 1e6) { // not DB - reset in drop database
+                       $query = ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
+               }
+               $history[$_GET["db"]][] = $query; //! respect $_GET["ns"]
                return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
        }