]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
avoid an unnecessary hash lookup
[ikiwiki.git] / IkiWiki.pm
index bb7d46ccfb63f8de96a4246b49de1dea67d9b8ea..f57ef8c6c89d169cf8523d5f588b939f62d8d540 100644 (file)
@@ -2493,11 +2493,11 @@ sub match_glob ($$;@) {
 
        # Instead of converting the glob to a regex every time,
        # cache the compiled regex to save time.
-       if (!defined $glob_cache{$glob}) {
-               my $re = IkiWiki::glob2re($glob);
-               $glob_cache{$glob} = qr/^$re$/i;
+       my $re=$glob_cache{$glob};
+       unless (defined $re) {
+               $glob_cache{$glob} = $re = IkiWiki::glob2re($glob);
        }
-       if ($page=~ $glob_cache{$glob}) {
+       if ($page =~ $re) {
                if (! IkiWiki::isinternal($page) || $params{internal}) {
                        return IkiWiki::SuccessReason->new("$glob matches $page");
                }
@@ -2667,7 +2667,7 @@ sub match_user ($$;@) {
                return IkiWiki::ErrorReason->new("no user specified");
        }
 
-       if (defined $params{user} && $params{user}=~/^$regexp$/i) {
+       if (defined $params{user} && $params{user}=~$regexp) {
                return IkiWiki::SuccessReason->new("user is $user");
        }
        elsif (! defined $params{user}) {