Skip to Content.
Sympa Menu

en - Re: [sympa-users] Adding a delivery type - html_summary - patches for 4.0b2

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: Mark Valiukas <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-users] Adding a delivery type - html_summary - patches for 4.0b2
  • Date: Wed, 11 Feb 2004 10:50:28 +1100

Chris Hastie wrote:

Would not this, which only cycles through the list once, be rather more efficient:

## Create the list of subscribers in various digest modes
for (my $user = $self->get_first_user(); $user; $user = $self->get_next_user()) {
push @tabrcpt, $user->{'email'}
if $user->{'reception'} eq "digest";
push @tabrcptsummary, $user->{'email'}
if $user->{'reception'} eq "summary";
push @tabrcpthtmlsummary, $user->{'email'}
if $user->{'reception'} eq "html_summary";
}

or is there some problem with this sort of thing that I've missed altogether?

At first glance, your suggestion would appear to be more efficient.

The historical reasons for the current approach are something
for Olivier et al to answer, I think, but the main reason I
continued along the original path rather than diverging to
something like your suggestion is that "it works" and "it's
easy to understand" - both of which are very important in the
early stages of any new feature IMO. Given that I've got
non-standard cruft in Lists.pm on my development machine already,
I can't see any reason not to incorporate your suggestion
into my version, other than that there may be a better way
to make the improvement.

There's all sorts of ideas in circulation for a case statement in
Perl; I think the one I like most is Switch, preferably with the
Perl 6 syntax turned on so there will be fewer headaches when 6
finally arrives. Something like the following (untested) might
be good:

============
use Switch 'Perl6';
.
.
## Create the list of subscribers in various digest modes finally comes
out:
for (my $user = $self->get_first_user(); $user; $user = $self->get_next_user()) {
my $user_reception = $user->('reception');
given ($user_reception) {
when "html_summary" {push @tabrcpthtmlsummary, $user->{'email'}; } when "summary" {push @tabrcptsummary, $user->{'email'}; }
when "digest" {push @tabrcpt, $user->{'email'}; }
}
}
============

The question, though, is how does it perform in the real world?
We've got one interation through the subscriber list in both
your new and my new suggestions instead of three. Yours does three
comparisons each iteration, mine does at least one and at most three
depending on the subscriber's settings. How would the additional
overhead from using Switch affect mine though? Am I really gaining
anything, or would I just be bloating things?


And thanks for the heads-up on Commands.pm too, Chris - I missed
that one. Probably mostly because setting options by mail isn't
likely to be terribly important to my users, and thus wasn't
something I was looking for.


--
Mark Valiukas



Archive powered by MHonArc 2.6.19+.

Top of Page