Permalink
Browse files

Avoid big ternary (save memory)

  • Loading branch information...
1 parent 2671a47 commit 0bc930c52af0a65080465065f41a995bd7bab0e6 @vrana committed Mar 22, 2011
Showing with 4 additions and 4 deletions.
  1. +4 −4 adminer/include/adminer.inc.php
@@ -408,10 +408,10 @@ function messageQuery($query) {
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>';
}

0 comments on commit 0bc930c

Please sign in to comment.