This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 878276bff3744f989e2eeff59e4f2afe5cd40588 Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Wed Aug 28 13:56:31 2024 -0700 Fix performance issues in cripts::Random (#11748) (cherry picked from commit 5b49be1f0c5a6f8464f383e32f150040d6790708) --- include/cripts/Lulu.hpp | 1 - src/cripts/Lulu.cc | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/cripts/Lulu.hpp b/include/cripts/Lulu.hpp index 79e8c8dc41..52c489051b 100644 --- a/include/cripts/Lulu.hpp +++ b/include/cripts/Lulu.hpp @@ -17,7 +17,6 @@ */ #pragma once -#include <random> #include <filesystem> #include <cstring> diff --git a/src/cripts/Lulu.cc b/src/cripts/Lulu.cc index 368001817a..85a2702b3f 100644 --- a/src/cripts/Lulu.cc +++ b/src/cripts/Lulu.cc @@ -24,6 +24,7 @@ #include "cripts/Preamble.hpp" #include "tsutil/StringConvert.h" +#include "tscore/Random.h" #if CRIPTS_HAS_MAXMIND #include <maxminddb.h> @@ -69,11 +70,7 @@ integer_helper(std::string_view sv) int cripts::Random(int max) { - static std::random_device r; - static std::default_random_engine e1(r()); - std::uniform_int_distribution<int> uniform_dist(1, max); - - return uniform_dist(e1); + return ts::Random::random() % max + 1; // [1..max] } namespace cripts::details