[Lxr-commits] CVS: lxr/lib/LXR/Lang Generic.pm,1.8,1.9
Brought to you by:
ajlittoz
|
From: Malcolm B. <mb...@us...> - 2001-11-28 12:59:54
|
Update of /cvsroot/lxr/lxr/lib/LXR/Lang
In directory usw-pr-cvs1:/tmp/cvs-serv30982/lib/LXR/Lang
Modified Files:
Generic.pm
Log Message:
Apply speedup patch from Arne.
Makes Generic.pm only read the config file once, and then share the info
between instances.
Index: Generic.pm
===================================================================
RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Generic.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Generic.pm 2001/11/18 03:31:34 1.8
+++ Generic.pm 2001/11/28 12:59:51 1.9
@@ -30,6 +30,8 @@
use vars qw($AUTOLOAD);
+my $generic_config;
+
@LXR::Lang::Generic::ISA = ('LXR::Lang');
sub new {
@@ -39,29 +41,37 @@
bless ($self, $class);
$$self{'release'} = $release;
$$self{'language'} = $lang;
-
- open (X, $config->genericconf) || die "Can't open $config->genericconf, $!";
-
- local($/) = undef;
- my $cfg = eval ("\n#line 1 \"generic.conf\"\n".
- <X>);
- die ($@) if $@;
- close X;
- %$self= (%$self, %$cfg);
+ read_config() unless defined $generic_config;
+ %$self = (%$self, %$generic_config);
# Set langid
$$self{'langid'} = $self->langinfo('langid');
die "No langid for language $lang" if !defined $self->langid;
-
- # Setup the ctags to declid mapping
- my $typemap =\%{$self->langinfo('typemap')};
-
- foreach my $type (keys %$typemap) {
- $typemap->{$type}=$index->getdecid($self->langid, $typemap->{$type});
- }
return $self;
+}
+
+sub read_config {
+ open (CONF, $config->genericconf) || die "Can't open $config->genericconf, $!";
+
+ local($/) = undef;
+
+ $generic_config = eval ("\n#line 1 \"generic.conf\"\n".
+ <CONF>);
+ die ($@) if $@;
+ close CONF;
+
+ # Setup the ctags to declid mapping
+ my $langmap = $generic_config->{'langmap'};
+ foreach my $lang (keys %$langmap) {
+ my $typemap = $langmap->{$lang}{'typemap'};
+ foreach my $type (keys %$typemap) {
+ $typemap->{$type} =
+ $index->getdecid($langmap->{$lang}{'langid'},
+ $typemap->{$type});
+ }
+ }
}
sub indexfile {
|