Browse Source

Port optimizations from #6232

Port the code optimizations without the method renames and readability
changes.
mark_story 11 years ago
parent
commit
298aaf5b07
2 changed files with 4 additions and 11 deletions
  1. 3 7
      src/Cache/Engine/FileEngine.php
  2. 1 4
      src/Core/ObjectRegistry.php

+ 3 - 7
src/Cache/Engine/FileEngine.php

@@ -294,11 +294,10 @@ class FileEngine extends CacheEngine
      */
     protected function _clearDirectory($path, $now, $threshold)
     {
-        $prefixLength = strlen($this->_config['prefix']);
-
         if (!is_dir($path)) {
             return;
         }
+        $prefixLength = strlen($this->_config['prefix']);
 
         $dir = dir($path);
         while (($entry = $dir->read()) !== false) {
@@ -314,12 +313,11 @@ class FileEngine extends CacheEngine
 
             if ($threshold) {
                 $mtime = $file->getMTime();
-
                 if ($mtime > $threshold) {
                     continue;
                 }
-                $expires = (int)$file->current();
 
+                $expires = (int)$file->current();
                 if ($expires > $now) {
                     continue;
                 }
@@ -395,9 +393,7 @@ class FileEngine extends CacheEngine
             }
             unset($path);
 
-            if (!$exists &&
-                !chmod($this->_File->getPathname(), (int)$this->_config['mask'])
-            ) {
+            if (!$exists && !chmod($this->_File->getPathname(), (int)$this->_config['mask'])) {
                 trigger_error(sprintf(
                     'Could not apply permission mask "%s" on cache file "%s"',
                     $this->_File->getPathname(),

+ 1 - 4
src/Core/ObjectRegistry.php

@@ -110,10 +110,7 @@ abstract class ObjectRegistry
     {
         $existing = $this->_loaded[$name];
         $msg = sprintf('The "%s" alias has already been loaded', $name);
-        $hasConfig = false;
-        if (method_exists($existing, 'config')) {
-            $hasConfig = true;
-        }
+        $hasConfig = method_exists($existing, 'config');
         if (!$hasConfig) {
             throw new RuntimeException($msg);
         }