chocoteam / choco-solver

An open-source Java library for Constraint Programming
http://choco-solver.org/
BSD 4-Clause "Original" or "Old" License
690 stars 143 forks source link

Reduce object creation during solving #985

Closed cprudhom closed 1 year ago

jgFages commented 1 year ago

Would you say more generally that one should avoid :

cprudhom commented 1 year ago

Using stream during the resolution should be carefully done. If an alternative exists without stream, it should be preferred. Note, that it could require the introduction of new method (like I did with Variable.forEachPropagator).

Using lambdas is more or less the same. If predefined functions/consumers/... can be extracted, that's better: profiling is easier and it limits the creation of objects (but it might increase the size of a model...). Using lambda to save IOperation is OK, though, because a new instance is necessary.

jgFages commented 1 year ago

Thanks. It confirms my experience of streams within algorithms.