http://bugzilla.spamassassin.org/show_bug.cgi?id=3852
------- Additional Comments From [EMAIL PROTECTED] 2004-10-05 16:13 -------
' - Most scalar accesses to $conf->{config_item_name} become accesses to
$conf->get(ID). ID is a numeric constant exported by Constants.pm. (why use
numeric constants? Simple -- looking up values in a hashref using string
hash-keys is slower than looking up values in an arrayref using integer
indexes.)'
Better idea. we can actually do similar to what PerMsgStatus does, for speed;
precompile the accessor functions. when we parse the list of available config
items, note the ones that are scalars. foreach item: generate accessor method
like so:
sub cf_$ITEMNAME {
my ($self) = @_;
return $self->{sys}{$ITEMNAME};
}
in calling code, call like so:
my $var = $conf->cf_ITEMNAME();
the benefit -- it allows perl to precalculate the hashes, which gives about a
6-7% speedup. For the $var->$conf->cf_get("ITEMNAME") case, you have:
1. look up "cf_get" in $conf package stash (prehashed)
2. look up "ITEMNAME" in $conf->{sys} hash (this is not prehashed)
3. return value
in the new case:
1. look up "cf_get_ITEMNAME" in $conf package stash (prehashed)
2. look up "ITEMNAME" in $conf->{sys} hash (prehashed)
3. return value
still thinking about this, though. but it looks like a good speedup... it
should also help with RAM, too, I think, since hash keys use a single global
refcounted pool of string singletons, so multiple refs to {name_of_config_item}
as a hash key are stored as only 1 string internally.
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.