From e06d1fea267c3e47f84f345641ff256beec7730f Mon Sep 17 00:00:00 2001 From: zvonand Date: Mon, 19 Feb 2024 15:18:05 +0100 Subject: [PATCH] use insert return value to check uniqueness --- src/Disks/StoragePolicy.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Disks/StoragePolicy.cpp b/src/Disks/StoragePolicy.cpp index 529201f7740..390afb368f8 100644 --- a/src/Disks/StoragePolicy.cpp +++ b/src/Disks/StoragePolicy.cpp @@ -68,14 +68,11 @@ StoragePolicy::StoragePolicy( volumes.emplace_back(createVolumeFromConfig(attr_name, config, volumes_prefix + "." + attr_name, disks)); UInt64 last_priority = volumes.back()->volume_priority; - if (last_priority != std::numeric_limits::max()) + if (last_priority != std::numeric_limits::max() && !volume_priorities.insert(last_priority).second) { - if (volume_priorities.find(last_priority) == volume_priorities.end()) - volume_priorities.insert(last_priority); - else - throw Exception( - ErrorCodes::INVALID_CONFIG_PARAMETER, - "volume_priority values must be unique across the policy"); + throw Exception( + ErrorCodes::INVALID_CONFIG_PARAMETER, + "volume_priority values must be unique across the policy"); } }