Some more small speed tweaks.
This commit is contained in:
parent
bf49c7ce19
commit
cc95eb5deb
@ -39,7 +39,7 @@ class PageRequestEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if path is not specified, use the default front page
|
// if path is not specified, use the default front page
|
||||||
if(strlen($path) === 0) {
|
if(empty($path)) { /* empty is faster than strlen */
|
||||||
$path = $config->get_string('front_page');
|
$path = $config->get_string('front_page');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,9 @@ class CommandEvent extends Event {
|
|||||||
|
|
||||||
$opts = array();
|
$opts = array();
|
||||||
$log_level = SCORE_LOG_WARNING;
|
$log_level = SCORE_LOG_WARNING;
|
||||||
for($i=1; $i<count($args); $i++) {
|
$arg_count = count($args);
|
||||||
|
|
||||||
|
for($i=1; $i<$arg_count; $i++) {
|
||||||
switch($args[$i]) {
|
switch($args[$i]) {
|
||||||
case '-u':
|
case '-u':
|
||||||
$user = User::by_name($args[++$i]);
|
$user = User::by_name($args[++$i]);
|
||||||
|
@ -148,7 +148,9 @@ class Image {
|
|||||||
public static function count_images($tags=array()) {
|
public static function count_images($tags=array()) {
|
||||||
assert(is_array($tags));
|
assert(is_array($tags));
|
||||||
global $database;
|
global $database;
|
||||||
if(count($tags) == 0) {
|
$tag_count = count($tags);
|
||||||
|
|
||||||
|
if($tag_count == 0) {
|
||||||
$total = $database->cache->get("image-count");
|
$total = $database->cache->get("image-count");
|
||||||
if(!$total) {
|
if(!$total) {
|
||||||
$total = $database->get_one("SELECT COUNT(*) FROM images");
|
$total = $database->get_one("SELECT COUNT(*) FROM images");
|
||||||
@ -156,7 +158,7 @@ class Image {
|
|||||||
}
|
}
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
else if(count($tags) == 1 && !preg_match("/[:=><\*\?]/", $tags[0])) {
|
else if($tag_count == 1 && !preg_match("/[:=><\*\?]/", $tags[0])) {
|
||||||
$term = Tag::resolve_alias($tags[0]);
|
$term = Tag::resolve_alias($tags[0]);
|
||||||
return $database->get_one(
|
return $database->get_one(
|
||||||
$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"),
|
$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"),
|
||||||
@ -578,13 +580,14 @@ class Image {
|
|||||||
$_flexihash = new Flexihash();
|
$_flexihash = new Flexihash();
|
||||||
foreach(explode(",", $opts) as $opt) {
|
foreach(explode(",", $opts) as $opt) {
|
||||||
$parts = explode("=", $opt);
|
$parts = explode("=", $opt);
|
||||||
|
$parts_count = count($parts);
|
||||||
$opt_val = "";
|
$opt_val = "";
|
||||||
$opt_weight = 0;
|
$opt_weight = 0;
|
||||||
if(count($parts) == 2) {
|
if($parts_count == 2) {
|
||||||
$opt_val = $parts[0];
|
$opt_val = $parts[0];
|
||||||
$opt_weight = $parts[1];
|
$opt_weight = $parts[1];
|
||||||
}
|
}
|
||||||
elseif(count($parts) == 1) {
|
elseif($parts_count == 1) {
|
||||||
$opt_val = $parts[0];
|
$opt_val = $parts[0];
|
||||||
$opt_weight = 1;
|
$opt_weight = 1;
|
||||||
}
|
}
|
||||||
@ -652,7 +655,7 @@ class Image {
|
|||||||
$positive = false;
|
$positive = false;
|
||||||
$term = substr($term, 1);
|
$term = substr($term, 1);
|
||||||
}
|
}
|
||||||
if(strlen($term) == 0) {
|
if(strlen($term) === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Wiki extends Extension {
|
|||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
if($event->page_matches("wiki")) {
|
if($event->page_matches("wiki")) {
|
||||||
if(is_null($event->get_arg(0)) || strlen(trim($event->get_arg(0))) == 0) {
|
if(is_null($event->get_arg(0)) || strlen(trim($event->get_arg(0))) === 0) {
|
||||||
$title = "Index";
|
$title = "Index";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user