From 47f5ee42c97371efed7aa74a350c5e84bb66b04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 11 Sep 2020 20:18:09 +0200 Subject: [PATCH] [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. --- tools/yulPhaser/Population.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/yulPhaser/Population.cpp b/tools/yulPhaser/Population.cpp index c4b506369..1dba2e2fd 100644 --- a/tools/yulPhaser/Population.cpp +++ b/tools/yulPhaser/Population.cpp @@ -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()) ); }