From 0a547f7d7db24f7c0a70f9cb5f0eedcc5d2ebec5 Mon Sep 17 00:00:00 2001 From: Jackarain Date: Wed, 22 Nov 2023 23:32:20 +0800 Subject: [PATCH] Use std::clamp instead of if condition --- proxy/include/proxy/proxy_server.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/proxy/include/proxy/proxy_server.hpp b/proxy/include/proxy/proxy_server.hpp index 5dabd8cbc9..bf1aa43103 100644 --- a/proxy/include/proxy/proxy_server.hpp +++ b/proxy/include/proxy/proxy_server.hpp @@ -380,8 +380,7 @@ R"x*x( static std::normal_distribution<> dis(5, 4); int num = static_cast(dis(gen)); - if (num < 0) num = 0; - if (num > 10) num = 10; + num = std::clamp(num, 0, 10); return pos[num]; }