From: Peter van Dijk Date: Fri, 19 Jan 2024 13:41:18 +0000 (+0100) Subject: reference instead of copy, and move some code for clarity X-Git-Tag: dnsdist-1.9.0-rc1~26^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c06dda72cea91fa9a4e9ec248776c2be4ba8b24b;p=thirdparty%2Fpdns.git reference instead of copy, and move some code for clarity --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 705fb3161f..fb69c2763d 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -736,9 +736,7 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn return allZerosIP; } } else if (!parts.empty()) { - // either hex string, or 12-13-14-15 - vector ip_parts; - auto input = parts[0]; + auto& input = parts.at(0); // allow a word without - in front, as long as it does not contain anything that could be a number size_t nonhexprefix = strcspn(input.c_str(), "0123456789abcdefABCDEF"); @@ -746,6 +744,9 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn input = input.substr(nonhexprefix); } + // either hex string, or 12-13-14-15 + vector ip_parts; + stringtok(ip_parts, input, "-"); unsigned int x1, x2, x3, x4; if (ip_parts.size() >= 4) {