More tweaks for minor speed gains.

This commit is contained in:
green-ponies (jgen) 2012-01-12 21:17:37 -05:00
parent 3f7646bc8b
commit 2c6b5128c6
3 changed files with 25 additions and 22 deletions

View file

@ -284,8 +284,11 @@ class Image {
*/ */
public function get_thumb_link() { public function get_thumb_link() {
global $config; global $config;
if(strlen($config->get_string('image_tlink')) > 0) {
return $this->parse_link_template($config->get_string('image_tlink')); $image_tlink = $config->get_string('image_tlink'); // store a copy for speed.
if( !empty($image_tlink) ) { /* empty is faster than strlen */
return $this->parse_link_template($image_tlink);
} }
else if($config->get_bool('nice_urls', false)) { else if($config->get_bool('nice_urls', false)) {
return $this->parse_link_template(make_link('_thumbs/$hash/thumb.jpg')); return $this->parse_link_template(make_link('_thumbs/$hash/thumb.jpg'));

View file

@ -69,12 +69,12 @@ EOD;
$next = $page_number + 1; $next = $page_number + 1;
$u_tags = url_escape(implode(" ", $search_terms)); $u_tags = url_escape(implode(" ", $search_terms));
$query = empty($u_tags) ? "" : "/$u_tags"; $query = empty($u_tags) ? "" : '/'.$u_tags;
$h_prev = ($page_number <= 1) ? "Prev" : "<a href='".make_link("post/list$query/$prev")."'>Prev</a>"; $h_prev = ($page_number <= 1) ? "Prev" : '<a href="'.make_link('post/list'.$query.'/'.$prev).'">Prev</a>';
$h_index = "<a href='".make_link()."'>Index</a>"; $h_index = "<a href='".make_link()."'>Index</a>";
$h_next = ($page_number >= $total_pages) ? "Next" : "<a href='".make_link("post/list$query/$next")."'>Next</a>"; $h_next = ($page_number >= $total_pages) ? "Next" : '<a href="'.make_link('post/list'.$query.'/'.$next).'">Next</a>';
$h_search_string = html_escape(implode(" ", $search_terms)); $h_search_string = html_escape(implode(" ", $search_terms));
$h_search_link = make_link(); $h_search_link = make_link();
@ -102,7 +102,7 @@ EOD;
</form> </form>
<div id='search_completions'></div>"; <div id='search_completions'></div>";
return "$h_prev | $h_index | $h_next<br>$h_search"; return $h_prev.' | '.$h_index.' | '.$h_next.'<br>'.$h_search;
} }
protected function build_table($images, $query) { protected function build_table($images, $query) {

View file

@ -29,13 +29,13 @@ class Themelet {
*/ */
public function build_thumb_html(Image $image, $query=null) { public function build_thumb_html(Image $image, $query=null) {
global $config; global $config;
$i_id = int_escape($image->id); $i_id = (int) $image->id;
$h_view_link = make_link("post/view/$i_id", $query); $h_view_link = make_link('post/view/'.$i_id, $query);
$h_thumb_link = $image->get_thumb_link(); $h_thumb_link = $image->get_thumb_link();
// Removes the size tag if the file is an mp3 // Removes the size tag if the file is an mp3
if($image->ext == 'mp3'){ if($image->ext === 'mp3'){
$iitip = $image->get_tooltip(); $iitip = $image->get_tooltip();
$mp3tip = array("0x0"); $mp3tip = array("0x0");
$h_tip = str_replace($mp3tip, " ", $iitip); $h_tip = str_replace($mp3tip, " ", $iitip);
@ -53,21 +53,21 @@ class Themelet {
// If file is flash or svg then sets thumbnail to max size. // If file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg'){ if($image->ext === 'swf' || $image->ext === 'svg'){
$tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); }
else{ else{
$tsize = get_thumbnail_size($image->width, $image->height); } $tsize = get_thumbnail_size($image->width, $image->height); }
return " return '
<!-- cancel border --> <!-- cancel border -->
<div class='thumbblock'> <div class="thumbblock">
<div class='thumb'> <div class="thumb">
<a href='$h_view_link' style='position: relative; display: block; height: {$tsize[1]}px; width: {$tsize[0]}px;'> <a href="'.$h_view_link.'" style="position: relative; display: block; height: '.$tsize[1].'px; width: '.$tsize[0].'px;">
<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'> <img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'">
</a> </a>
</div> </div>
</div> </div>
"; ';
} }
@ -81,8 +81,8 @@ class Themelet {
} }
private function gen_page_link($base_url, $query, $page, $name) { private function gen_page_link($base_url, $query, $page, $name) {
$link = make_link("$base_url/$page", $query); $link = make_link($base_url.'/'.$page, $query);
return "<a href='$link'>$name</a>"; return '<a href="'.$link.'">'.$name.'</a>';
} }
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
@ -116,8 +116,8 @@ class Themelet {
} }
$pages_html = implode(" | ", $pages); $pages_html = implode(" | ", $pages);
return "<p class='paginator'>$first_html | $prev_html | $random_html | $next_html | $last_html". return '<p class="paginator">'.$first_html.' | '.$prev_html.' | '.$random_html.' | '.$next_html.' | '.$last_html
"<br>&lt;&lt; $pages_html &gt;&gt;</p><!-- cancel border -->"; .'<br>&lt;&lt; '.$pages_html.' &gt;&gt;</p><!-- cancel border -->';
} }
} }
?> ?>