[yul-phaser] isFitter(): Switch from toString() to genes() to make chromosome comparisons a tiny bit faster

- toString() uses a stream for conversion while genes() returns a direct reference to the string, without copies in between. The speed up is very small compared to the improvement from switching to storing a string of abbreviations instead of a vector of step names inside chromosomes but there's basically no downside to this change so it's still worth it.
This commit is contained in:
Kamil Śliwak 2020-09-11 20:18:09 +02:00
parent e024032a67
commit 47f5ee42c9

View File

@ -54,7 +54,7 @@ bool phaser::isFitter(Individual const& a, Individual const& b)
return (
(a.fitness < b.fitness) ||
(a.fitness == b.fitness && a.chromosome.length() < b.chromosome.length()) ||
(a.fitness == b.fitness && a.chromosome.length() == b.chromosome.length() && toString(a.chromosome) < toString(b.chromosome))
(a.fitness == b.fitness && a.chromosome.length() == b.chromosome.length() && a.chromosome.genes() < b.chromosome.genes())
);
}