friguzzi / cplint

cplint is a suite of programs for reasoning with probabilistic logic programs
Other
68 stars 13 forks source link

Expensive use of findall/3 #31

Closed pmoura closed 5 years ago

pmoura commented 5 years ago

The following goal is costly and a bad programming idiom:

https://github.com/friguzzi/cplint/blob/5fa2d56991729b8d37b6ea9c7c2ca9184462b32f/prolog/viterbi.pl#L56

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.

friguzzi commented 5 years ago

Thanks, fixed in 242814b87dca800eacccf88657e518175592e82e

pmoura commented 5 years ago

That was fast! 🙂