Skip to content

Short-circuit evaluation in validity checks #293

@jcoupey

Description

@jcoupey

In numerous situations, deciding if a local search move is valid is the result of calling several functions in a row to check validity with regard to skills, capacity, time windows etc.

The current code-base usually uses something along the lines of:

bool valid = first_check();
valid &= another_check();
...
return valid;

This code does generate unnecessary checks because another_check it still called even if first_check returned false.

We should use operator&& instead to get the intended short-circuit evaluation behaviour.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions