[Koha-devel] page size & speed display
MJ Ray
mjr at phonecoop.coop
Tue Jul 1 18:06:10 CEST 2008
Frederic Demians <frederic at tamil.fr> wrote:
> So reading config file may be not so slow but it is called 23 times! If
> you add a warning in this procedure, you see it is called from those
> modules: [...]
Why isn't it as simple as caching the result, as in
diff --git a/C4/Context.pm b/C4/Context.pm
index 3cba0ff..1cdca9b 100644
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@ -17,7 +17,7 @@ package C4::Context;
# Suite 330, Boston, MA 02111-1307 USA
use strict;
-use vars qw($VERSION $AUTOLOAD $context @context_stack);
+use vars qw($VERSION $AUTOLOAD $context @context_stack %config);
BEGIN {
if ($ENV{'HTTP_USER_AGENT'}) {
@@ -227,8 +227,11 @@ Returns undef in case of error.
=cut
sub read_config_file { # Pass argument naming config file to read
- my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
- return $koha; # Return value: ref-to-hash holding the configuration
+ my $filename = shift;
+ if ( !defined($config{$filename}) ) {
+ $config{$filename} = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo']);
+ }
+ return $config{$filename}; # Return value: ref-to-hash holding the configuration
}
# db_scheme2dbi
? I guess we could do a bit better by caching and cloning the
C4::Context $self hashref but that seems a bit trickier to me.
> > Finally, CumulS(XML::LibXML::SAX::_parse) >
> > CumulS(C4::Context::read_config_file) which reminds me that
> > koha-conf.xml isn't the only XML file in Koha - are others used here?
>
> marcxml biblio records? Even on a setup without XSLT?
I think so. I don't recall setting up XSLT explicitly, but I've
certainly had errors about invalid marcxml spat at me.
Thanks for investigating this,
--
MJ Ray (slef)
Webmaster for hire, statistician and online shop builder for a small
worker cooperative http://www.ttllp.co.uk/ http://mjr.towers.org.uk/
(Notice http://mjr.towers.org.uk/email.html) tel:+44-844-4437-237
_______________________________________________
Koha-devel mailing list
Koha-devel at lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-devel
More information about the Koha-devel
mailing list