aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart van Bragt <phpbb@vanbragt.com>2011-04-21 04:21:09 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2011-04-21 04:21:09 -0400
commit11dd4b54fa1f3a15448271061e51907e3ba5c79d (patch)
treefc0aeb3678a2b95a35f83231eb42fab5ace1156d
parent32bc980ca06b67789d8fd86e4c3a5c897a6de23f (diff)
downloadforums-11dd4b54fa1f3a15448271061e51907e3ba5c79d.tar
forums-11dd4b54fa1f3a15448271061e51907e3ba5c79d.tar.gz
forums-11dd4b54fa1f3a15448271061e51907e3ba5c79d.tar.bz2
forums-11dd4b54fa1f3a15448271061e51907e3ba5c79d.tar.xz
forums-11dd4b54fa1f3a15448271061e51907e3ba5c79d.zip
[ticket/10141] Use a cache in $auth->_fill_acl() for better performance.
Many sequences being converted are the same. Use a local cache to convert each sequence once, speeding up the function. PHPBB3-10141
-rw-r--r--phpBB/includes/auth.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php
index 02819f9e78..22fafd7b7f 100644
--- a/phpBB/includes/auth.php
+++ b/phpBB/includes/auth.php
@@ -109,6 +109,7 @@ class auth
*/
function _fill_acl($user_permissions)
{
+ $seq_cache = array();
$this->acl = array();
$user_permissions = explode("\n", $user_permissions);
@@ -125,8 +126,15 @@ class auth
while ($subseq = substr($seq, $i, 6))
{
- // We put the original bitstring into the acl array
- $this->acl[$f] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT);
+ if (isset($seq_cache[$subseq]))
+ {
+ $this->acl[$f] .= $seq_cache[$subseq];
+ }
+ else
+ {
+ // We put the original bitstring into the acl array
+ $this->acl[$f] .= ($seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT));
+ }
$i += 6;
}
}