diff --git a/CMakeLists.txt b/CMakeLists.txt index c928b1b9cb8..9a6f33fe683 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,6 @@ option(PORTABLE "build a portable binary (disable arch-specific optimizations)" # TODO: set ENABLE_NEW_ENCODING to ON when we are ready option(ENABLE_NEW_ENCODING "enable new encoding (#1033) for storing 64bit size and expire time in milliseconds" OFF) -set(CMAKE_LINK_DEPENDS_NO_SHARED 1) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() @@ -63,6 +61,12 @@ set(DEPS_FETCH_PROXY "" CACHE STRING "a template URL to proxy the traffic for fetching dependencies, e.g. with DEPS_FETCH_PROXY = https://some-proxy/, https://example/some-dep.zip -> https://some-proxy/https://example/some-dep.zip") +if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None") + set (CMAKE_BUILD_TYPE "RelWithDebInfo") + message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}") +endif () +message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") + if(ENABLE_ASAN AND ENABLE_TSAN) message(FATAL_ERROR "ASan and TSan cannot be used at the same time") endif() @@ -166,12 +170,6 @@ if ((PROJECT_VERSION STREQUAL "unstable") AND (GIT_SHA STREQUAL "")) endif () configure_file(src/version.h.in ${PROJECT_BINARY_DIR}/version.h) -if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None") - set (CMAKE_BUILD_TYPE "RelWithDebInfo") - message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}") -endif () -message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") - if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc") diff --git a/src/cluster/cluster.cc b/src/cluster/cluster.cc index 1e4f1d6c154..2a63383c5dd 100644 --- a/src/cluster/cluster.cc +++ b/src/cluster/cluster.cc @@ -137,8 +137,7 @@ Status Cluster::SetSlot(const std::string &slots_str, const std::string &node_id // 3. Update the map of slots to nodes. // remember: The atomicity of the process is based on // the transactionality of ClearKeysOfSlot(). - for (const auto &slot_range : slots) { - int s_start = slot_range.first, s_end = slot_range.second; + for (auto [s_start, s_end] : slots) { for (int slot = s_start; slot <= s_end; slot++) { std::shared_ptr old_node = slots_nodes_[slot]; if (old_node != nullptr) { @@ -660,15 +659,14 @@ Status Cluster::parseSlotRanges(const std::string &slots_str, std::vector{0, kClusterSlots - 1}; - // Parse all slots(include slot ranges) + // Parse all slots (include slot ranges) for (auto &slot_range : slot_ranges) { if (slot_range.find('-') == std::string::npos) { auto parse_result = ParseInt(slot_range, valid_range, 10); if (!parse_result) { return {Status::NotOK, errInvalidSlotID}; } - int slot_start = *parse_result; - slots.emplace_back(std::make_pair(slot_start, slot_start)); + slots.emplace_back(*parse_result, *parse_result); continue; } @@ -690,9 +688,7 @@ Status Cluster::parseSlotRanges(const std::string &slots_str, std::vector *slot_infos); @@ -104,7 +104,7 @@ class Cluster { std::string genNodesInfo(); void updateSlotsInfo(); SlotInfo genSlotNodeInfo(int start, int end, const std::shared_ptr &n); - static Status parseSlotRanges(const std::string&slots_str,std::vector> &slots); + static Status parseSlotRanges(const std::string &slots_str, std::vector> &slots); static Status parseClusterNodes(const std::string &nodes_str, ClusterNodes *nodes, std::unordered_map *slots_nodes); Server *svr_;