procmail
[Top] [All Lists]

views of efficiency

1997-11-14 09:15:14
When I felt that at a certain point the complexity of an internal-to-procmail
answer for Adam Grove's question outweighed the CPU load of forking a
program, Era Eriksson wrote,

| But Adam specifically asked for an efficient solution.

There's efficiency in every run-time, and there's efficiency in getting some-
thing that works up and keeping it running.  Given enough runs the former
will outstrip the latter for raw count of picoseconds, but when the former
saves computer cycles and the latter saves brain cycles, which to choose is
not so easily decided.

| Oh well, yet another case where (.*$)\{0,50\} would be a very welcome form
| of syntactic sugar.

Absolutely (actually, ^^(.*$)\{0,49\}.*pattern for Adam's question).  It
beats the antpays off

^^(.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$)?\
  (.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$)?\
  (.*$.*$.*$.*$.*$.*$.*$.*$)?(.*$.*$.*$.*$)?(.*$.*$)?(.*$)?.*pattern

especially when he wants to test the top fifty lines again and again for
various spam indicators, as he has since said, so he'd need to have several
recipes like that.  I think that with three or four it might actually save
CPU cycles as well as brain cycles to suck the stuff into a variable with
head once and for all.  And even then we can do this,

  :0B
  * ^^\/(.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$)?\
        (.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$.*$)?\
        (.*$.*$.*$.*$.*$.*$.*$.*$)?(.*$.*$.*$.*$)?(.*$.*$)?(.*$)?
  { toplines=$MATCH }

and then

  * w^x toplines ?? pattern

in subsequent recipes.