summaryrefslogtreecommitdiff
path: root/includes/registry.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-11 22:39:59 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-11 22:39:59 +0000
commit59ece2e39d28ba6052ea67d7770297b93a29d243 (patch)
tree212d76aad3f27766f0fc60540d8fa0e828b820b1 /includes/registry.inc
parent9d631d22f920796287041408dd8cf090370bac72 (diff)
downloadbrdo-59ece2e39d28ba6052ea67d7770297b93a29d243.tar.gz
brdo-59ece2e39d28ba6052ea67d7770297b93a29d243.tar.bz2
- Patch #325665 by chx, Damien Tournoud, justinrandell et al: improved the cache registry lookups.
Diffstat (limited to 'includes/registry.inc')
-rw-r--r--includes/registry.inc22
1 files changed, 20 insertions, 2 deletions
diff --git a/includes/registry.inc b/includes/registry.inc
index c02811182..ec968dd2a 100644
--- a/includes/registry.inc
+++ b/includes/registry.inc
@@ -69,10 +69,26 @@ function _registry_rebuild() {
->execute();
}
}
- _registry_parse_files($files);
+ $parsed_files = _registry_parse_files($files);
+
+ $unchanged_resources = array();
+ foreach (_registry_get_lookup_cache() as $key => $file) {
+ // If the file for this cached resource is carried over unchanged from
+ // the last registry build, then we can safely re-cache it.
+ if ($file && in_array($file, array_keys($files)) && !in_array($file, $parsed_files)) {
+ $unchanged_resources[$key] = $file;
+ }
+ }
+ _registry_check_code(REGISTRY_RESET_LOOKUP_CACHE);
module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
cache_clear_all('*', 'cache_registry', TRUE);
+
+ // We have some unchanged resources, warm up the cache - no need to pay
+ // for looking them up again.
+ if (count($unchanged_resources) > 0) {
+ _registry_set_lookup_cache($unchanged_resources);
+ }
}
/**
@@ -92,12 +108,13 @@ function registry_get_parsed_files() {
* The list of files to check and parse.
*/
function _registry_parse_files($files) {
- $changed_files = array();
+ $parsed_files = array();
foreach ($files as $filename => $file) {
$contents = file_get_contents($filename);
$md5 = md5($contents);
$new_file = !isset($file['md5']);
if ($new_file || $md5 != $file['md5']) {
+ $parsed_files[] = $filename;
// We update the md5 after we've saved the files resources rather than here, so if we
// don't make it through this rebuild, the next run will reparse the file.
_registry_parse_file($filename, $contents, $file['module'], $file['weight']);
@@ -108,6 +125,7 @@ function _registry_parse_files($files) {
->execute();
}
}
+ return $parsed_files;
}
/**