Closed samuelfmlourenco closed 3 years ago
As implemented:
// "Equal to" operator for PROMConfig
bool CP2130::PROMConfig::operator ==(const CP2130::PROMConfig &other) const
{
bool equal = true;
for (size_t i = 0; i < PROM_BLOCKS; ++i) {
for (size_t j = 0; j < PROM_BLOCK_SIZE; ++j) {
if (blocks[i][j] != other.blocks[i][j]) {
equal = false;
break;
}
}
if (!equal) { // Added in version 2.0.1 in order to fix efficiency issue
break;
}
}
return equal;
}
The PROMConfig "equal to" operator should return immediately when a difference is found. Only the inner for cycle is being interrupted. The offending code:
The correct approach, while keeping one return point per function in order to respect the structured approach, should be this:
This will be fixed in the next release.