friguzzi/cplint

Expensive use of findall/3

Closed this issue · 2 comments

The following goal is costly and a bad programming idiom:

findall(_,find_exp(GL,M),_),

This is reported by the Logtalk linter (git version) as:

*     Suspicious call: findall(A,find_exp(B,C),D) instead of find_exp(B,C),fail;true
*       while compiling object viterbi
*       in file /Users/pmoura/Downloads/cplint-master/prolog/viterbi.pl between lines 48-62

As suggested in the warning message, using instead a (find_exp(B,C),fail;true) goal is both clear and faster.

Thanks, fixed in 242814b

That was fast! 🙂