Skip to content

Commit

Permalink
Optimize calls to strtoupper()
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Feb 24, 2016
1 parent ff1e1ec commit 3672068
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/includes/classes/AdvCacheBackCompat.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public static function zcRequestVars()
*/
public static function zenCacheConstants()
{
$_upper_global_ns = strtoupper(GLOBAL_NS);

if (!($constants = get_defined_constants(true)) || empty($constants['user'])) {
return; // Nothing to do; i.e. no user-defined constants.
}
Expand All @@ -54,14 +56,14 @@ public static function zenCacheConstants()
if (!($_constant_sub_name = substr($_constant, 9))) {
continue; // Nothing to do here.
}
if (!defined(strtoupper(GLOBAL_NS).'_'.$_constant_sub_name)) {
define(strtoupper(GLOBAL_NS).'_'.$_constant_sub_name, $_value);
if (!defined($_upper_global_ns.'_'.$_constant_sub_name)) {
define($_upper_global_ns.'_'.$_constant_sub_name, $_value);
}
}
unset($_constant, $_value); // Housekeeping.

if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[strtoupper(GLOBAL_NS).'_ALLOWED'])) {
$_SERVER[strtoupper(GLOBAL_NS).'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED'];
if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[$_upper_global_ns.'_ALLOWED'])) {
$_SERVER[$_upper_global_ns.'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED'];
}

unset($_constant, $_value, $_upper_global_ns); // Housekeeping.
}
}

0 comments on commit 3672068

Please sign in to comment.