yul-phaser: A few more tweaks to ensure that signedness conversions do not cause warnings

- Don't cast booleans to int when the result gets assigned to an unsigned type. Relace them with ifs.
- Use unsigned initializer for a variable declared in a lambda capture.
- Unsigned abs() of a difference of unsigned values.
This commit is contained in:
Djordje Mijovic
2020-06-04 17:18:07 +02:00
committed by Kamil Śliwak
parent a49a127627
commit 9b3d1c11ff
3 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -72,9 +72,13 @@ size_t phaser::test::countDifferences(Chromosome const& _chromosome1, Chromosome
{
size_t count = 0;
for (size_t i = 0; i < min(_chromosome1.length(), _chromosome2.length()); ++i)
count += static_cast<int>(_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i]);
if (_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i])
++count;
return count + abs(static_cast<int>(_chromosome1.length() - _chromosome2.length()));
return count + static_cast<size_t>(abs(
static_cast<long>(_chromosome1.length()) -
static_cast<long>(_chromosome2.length())
));
}
TemporaryDirectory::TemporaryDirectory(std::string const& _prefix):