Efficiency improvement to class manifest

This commit is contained in:
Daniel Hensby 2016-05-19 12:47:29 +01:00
parent be496c4e54
commit 118af06c3f
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E

View File

@ -347,8 +347,7 @@ class SS_ClassManifest {
// files will have changed and TokenisedRegularExpression is quite // files will have changed and TokenisedRegularExpression is quite
// slow. A combination of the file name and file contents hash are used, // slow. A combination of the file name and file contents hash are used,
// since just using the datetime lead to problems with upgrading. // since just using the datetime lead to problems with upgrading.
$file = file_get_contents($pathname); $key = preg_replace('/[^a-zA-Z0-9_]/', '_', $basename) . '_' . md5_file($pathname);
$key = preg_replace('/[^a-zA-Z0-9_]/', '_', $basename) . '_' . md5($file);
if ($data = $this->cache->load($key)) { if ($data = $this->cache->load($key)) {
$valid = ( $valid = (
@ -364,7 +363,7 @@ class SS_ClassManifest {
} }
if (!$classes) { if (!$classes) {
$tokens = token_get_all($file); $tokens = token_get_all(file_get_contents($pathname));
$classes = self::get_namespaced_class_parser()->findAll($tokens); $classes = self::get_namespaced_class_parser()->findAll($tokens);
$namespace = self::get_namespace_parser()->findAll($tokens); $namespace = self::get_namespace_parser()->findAll($tokens);