From c06dda72cea91fa9a4e9ec248776c2be4ba8b24b Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Fri, 19 Jan 2024 14:41:18 +0100 Subject: [PATCH] reference instead of copy, and move some code for clarity --- pdns/lua-record.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) { -- 2.47.2