From 57a51c475e707063e37c29e1101360aadbe9c956 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 25 Jun 2015 15:07:59 +0200 Subject: [PATCH] Increase readability and make sanitizer happy Increasing readability and making the clang sanitizer happy about the loop condition in EthereumHost.cpp --- libethereum/EthereumHost.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libethereum/EthereumHost.cpp b/libethereum/EthereumHost.cpp index 4a13a247f..9980f4339 100644 --- a/libethereum/EthereumHost.cpp +++ b/libethereum/EthereumHost.cpp @@ -178,8 +178,9 @@ tuple>, vector>, vector return true; }); - chosen.reserve((peerCount * _percent + 99) / 100); - for (unsigned i = (peerCount * _percent + 99) / 100; i-- && allowed.size();) + size_t chosenSize = (peerCount * _percent + 99) / 100; + chosen.reserve(chosenSize); + for (unsigned i = chosenSize; i && allowed.size(); i--) { unsigned n = rand() % allowed.size(); chosen.push_back(std::move(allowed[n]));