mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[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:
parent
e024032a67
commit
47f5ee42c9
@ -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())
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user