[Rt-commit] [svn] r1877 - in rt/branches/3.3-TESTING: .
html/Elements
autrijus at pallas.eruditorum.org
autrijus at pallas.eruditorum.org
Thu Nov 11 23:51:19 EST 2004
Author: autrijus
Date: Thu Nov 11 23:51:18 2004
New Revision: 1877
Modified:
rt/branches/3.3-TESTING/ (props changed)
rt/branches/3.3-TESTING/html/Elements/Callback
Log:
r3828 at not: autrijus | 2004-11-11T04:38:07.819422Z
* Do not waste stat() calls on Callback elements.
* If $RT::DevelMode is not set, do not refresh Callbacks cache at all.
Modified: rt/branches/3.3-TESTING/html/Elements/Callback
==============================================================================
--- rt/branches/3.3-TESTING/html/Elements/Callback (original)
+++ rt/branches/3.3-TESTING/html/Elements/Callback Thu Nov 11 23:51:18 2004
@@ -45,41 +45,29 @@
%# END BPS TAGGED BLOCK }}}
<%once>
my %cache;
-my $check = '';
</%once>
<%init>
-# checks for inode change time for each callback directory
-my $new_check = join(
- $;, map { $_->[1] => (stat("$_->[1]/Callbacks"))[10] } $m->interp->resolver->comp_root_array
-) or return;
-
$Page = $m->callers(1)->path unless ($Page);
-my $callbacks;
-if ($new_check eq $check) {
- $callbacks = $cache{$Page,$_CallbackName};
-}
-else {
- $check = $new_check;
-}
+my $CacheKey = "Callback--$Page--$_CallbackName";
+my $callbacks = $cache{$CacheKey} || $m->notes($CacheKey);
if (!$callbacks) {
my $path = "/Callbacks/*$Page/$_CallbackName";
- $callbacks = [ $m->interp->resolver->glob_path($path) ];
- @$callbacks = grep !/^\.|~$/, @$callbacks; #skip backup files
-
- #skip files without a package
- my $invalid_base = "/Callbacks/$Page/$_CallbackName";
- @$callbacks = grep !/^$invalid_base$/, @$callbacks;
-
+ $callbacks = [
+ # Skip backup files, and files without a leading package name
+ grep { !/^\.|~$/ and $_ ne "/Callbacks/$Page/$_CallbackName" }
+ $m->interp->resolver->glob_path($path)
+ ];
- $cache{$Page,$_CallbackName} = $callbacks;
+ $m->notes($CacheKey => $callbacks);
+ $cache{$Page,$_CallbackName} = $callbacks if !$RT::DevelMode;
}
my @rv;
foreach my $comp (sort @$callbacks) {
- push @rv, $m->comp($comp, %ARGS) if $m->comp_exists($comp);
+ push @rv, $m->comp($comp, %ARGS);
}
return @rv;
</%init>
More information about the Rt-commit
mailing list