[Dovecot] Dovecot-sieve processing optimizations

Eduardo M KALINOWSKI eduardo at kalinowski.com.br
Wed Oct 8 21:26:55 EEST 2008


Seth Mattinen escreveu:
> Roderick A. Anderson wrote:
>   
>> I'm working at the next part of the virtual domains mail server.  I'm
>> moving this account (raanders at acm.org is a forwarder) which has a bunch
>> of procmail rules to file into folders.
>>
>> My question is if it is more efficient is use?
>>
>> if  {
>>    ...
>> } elsif {
>>    ...
>> } elsif {
>>    ...
>> }
>> else
>>
>> This seems to be the way many of the example scripts do it but I found
>> at least one that used
>>
>> if {
>>    ...
>> }
>>
>> if {
>>    ...
>> }
>>
>> Which is more procmail like and for me reads easier.
>>
>> If not here where should I ask?
>>
>>     
>
> Well, both accomplish different things. In the first example, one and
> only one of the conditions will be executed. In the second one, more
> than one could possibly be executed.
>
> I've never looked at Sieve's code, but the first will stop at the first
> matching condition. In the second case, because you could make it do
> more than one thing, it must check each condition.
>   

If in each if you put a "finish" statement (or whatever is used to stop
processing the file), then the second one can be more efficient, since
it does not have to continue checking the file to see if there are
further conditions after the if/elseif/.../else block.

But in practice I doubt there is a practical difference between both.
You should use the one that is more readable for you.

-- 
Eduardo M Kalinowski
eduardo at kalinowski.com.br



More information about the dovecot mailing list