Skip to content

Commit

Permalink
Useless changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed May 10, 2024
1 parent 46c9947 commit ced5cc1
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 44 deletions.
2 changes: 1 addition & 1 deletion base/base/EnumReflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace detail
template <is_enum E, class F, size_t ...I>
constexpr void static_for(F && f, std::index_sequence<I...>)
{
(std::forward<F>(f)(std::integral_constant<E, magic_enum::enum_value<E>(I)>()) , ...);
(f(std::integral_constant<E, magic_enum::enum_value<E>(I)>()) , ...);
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/Common/ZooKeeper/ZooKeeperWithFaultInjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ zkutil::ZooKeeper::MultiTryGetResponse ZooKeeperWithFaultInjection::tryGet(const

void ZooKeeperWithFaultInjection::set(const String & path, const String & data, int32_t version, Coordination::Stat * stat)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->set(path, data, version, stat); });
executeWithFaultSync(__func__, path, [&]() { keeper->set(path, data, version, stat); });
}

void ZooKeeperWithFaultInjection::remove(const String & path, int32_t version)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->remove(path, version); });
executeWithFaultSync(__func__, path, [&]() { keeper->remove(path, version); });
}

bool ZooKeeperWithFaultInjection::exists(const std::string & path, Coordination::Stat * stat, const zkutil::EventPtr & watch)
Expand Down Expand Up @@ -352,18 +352,18 @@ Coordination::Responses ZooKeeperWithFaultInjection::multi(const Coordination::R

void ZooKeeperWithFaultInjection::createIfNotExists(const std::string & path, const std::string & data)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->createIfNotExists(path, data); });
executeWithFaultSync(__func__, path, [&]() { keeper->createIfNotExists(path, data); });
}

void ZooKeeperWithFaultInjection::createOrUpdate(const std::string & path, const std::string & data, int32_t mode)
{
chassert(mode != zkutil::CreateMode::EphemeralSequential && mode != zkutil::CreateMode::Ephemeral);
return executeWithFaultSync(__func__, path, [&]() { return keeper->createOrUpdate(path, data, mode); });
executeWithFaultSync(__func__, path, [&]() { keeper->createOrUpdate(path, data, mode); });
}

void ZooKeeperWithFaultInjection::createAncestors(const std::string & path)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->createAncestors(path); });
executeWithFaultSync(__func__, path, [&]() { keeper->createAncestors(path); });
}

Coordination::Error ZooKeeperWithFaultInjection::tryRemove(const std::string & path, int32_t version)
Expand All @@ -373,17 +373,17 @@ Coordination::Error ZooKeeperWithFaultInjection::tryRemove(const std::string & p

void ZooKeeperWithFaultInjection::removeRecursive(const std::string & path)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->removeRecursive(path); });
executeWithFaultSync(__func__, path, [&]() { keeper->removeRecursive(path); });
}

void ZooKeeperWithFaultInjection::tryRemoveRecursive(const std::string & path)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->tryRemoveRecursive(path); });
executeWithFaultSync(__func__, path, [&]() { keeper->tryRemoveRecursive(path); });
}

void ZooKeeperWithFaultInjection::removeChildren(const std::string & path)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->removeChildren(path); });
executeWithFaultSync(__func__, path, [&]() { keeper->removeChildren(path); });
}

bool ZooKeeperWithFaultInjection::tryRemoveChildrenRecursive(
Expand All @@ -410,14 +410,14 @@ ZooKeeperWithFaultInjection::trySet(const std::string & path, const std::string

void ZooKeeperWithFaultInjection::checkExistsAndGetCreateAncestorsOps(const std::string & path, Coordination::Requests & requests)
{
return executeWithFaultSync(__func__, path, [&]() { return keeper->checkExistsAndGetCreateAncestorsOps(path, requests); });
executeWithFaultSync(__func__, path, [&]() { keeper->checkExistsAndGetCreateAncestorsOps(path, requests); });
}

void ZooKeeperWithFaultInjection::deleteEphemeralNodeIfContentMatches(
const std::string & path, const std::string & fast_delete_if_equal_value)
{
return executeWithFaultSync(
__func__, path, [&]() { return keeper->deleteEphemeralNodeIfContentMatches(path, fast_delete_if_equal_value); });
executeWithFaultSync(
__func__, path, [&]() { keeper->deleteEphemeralNodeIfContentMatches(path, fast_delete_if_equal_value); });
}

Coordination::Error ZooKeeperWithFaultInjection::tryMulti(const Coordination::Requests & requests, Coordination::Responses & responses, bool check_session_valid)
Expand Down
1 change: 0 additions & 1 deletion src/Common/mysqlxx/PoolFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ static std::string getPoolEntryName(const Poco::Util::AbstractConfiguration & co
std::string port = config.getString(config_name + ".port", "");
std::string user = config.getString(config_name + ".user", "");
std::string db = config.getString(config_name + ".db", "");
std::string table = config.getString(config_name + ".table", "");

Poco::Util::AbstractConfiguration::Keys keys;
config.keys(config_name, keys);
Expand Down
3 changes: 2 additions & 1 deletion src/Coordination/KeeperServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,8 @@ void KeeperServer::applyConfigUpdateWithReconfigDisabled(const ClusterUpdateActi
"Trying to remove leader node (ourself), so will yield leadership and some other node "
"(new leader) will try to remove us. "
"Probably you will have to run SYSTEM RELOAD CONFIG on the new leader node");
return raft_instance->yield_leadership();
raft_instance->yield_leadership();
return;
}

for (size_t i = 0; i < coordination_settings->configuration_change_tries_count && !is_recovering; ++i)
Expand Down
8 changes: 3 additions & 5 deletions src/Coordination/KeeperStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,7 @@ struct KeeperStorageCreateRequestProcessor final : public KeeperStorageRequestPr
else if (parent_cversion > node.cversion)
node.cversion = parent_cversion;

if (zxid > node.pzxid)
node.pzxid = zxid;
node.pzxid = std::max(zxid, node.pzxid);
node.increaseNumChildren();
};

Expand Down Expand Up @@ -1353,9 +1352,8 @@ struct KeeperStorageRemoveRequestProcessor final : public KeeperStorageRequestPr
{
[zxid](KeeperStorage::Node & parent)
{
if (parent.pzxid < zxid)
parent.pzxid = zxid;
}
parent.pzxid = std::max(parent.pzxid, zxid);
}
}
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/Dictionaries/HierarchyDictionariesUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace detail
auto hierarchy_key = keys[i];
size_t current_hierarchy_depth = 0;

bool is_key_valid = std::forward<IsKeyValidFunc>(is_key_valid_func)(hierarchy_key);
bool is_key_valid = is_key_valid_func(hierarchy_key);

if (!is_key_valid)
{
Expand Down
1 change: 0 additions & 1 deletion src/Dictionaries/RegExpTreeDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,6 @@ void registerDictionaryRegExpTree(DictionaryFactory & factory)
"to represent regular expressions");
}

String dictionary_layout_prefix = config_prefix + ".layout" + ".regexp_tree";
const DictionaryLifetime dict_lifetime{config, config_prefix + ".lifetime"};

const auto dict_id = StorageID::fromDictionaryConfig(config, config_prefix);
Expand Down
16 changes: 8 additions & 8 deletions src/Functions/DateTimeTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ struct ToRelativeYearNumImpl
static auto execute(Int64 t, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int16>(time_zone.toYear(t));
return time_zone.toYear(t);
else
return static_cast<UInt16>(time_zone.toYear(t));
}
Expand All @@ -1701,7 +1701,7 @@ struct ToRelativeYearNumImpl
static auto execute(Int32 d, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int16>(time_zone.toYear(ExtendedDayNum(d)));
return time_zone.toYear(ExtendedDayNum(d));
else
return static_cast<UInt16>(time_zone.toYear(ExtendedDayNum(d)));
}
Expand All @@ -1722,7 +1722,7 @@ struct ToRelativeQuarterNumImpl
static auto execute(Int64 t, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeQuarterNum(t));
return time_zone.toRelativeQuarterNum(t);
else
return static_cast<UInt16>(time_zone.toRelativeQuarterNum(t));
}
Expand All @@ -1733,7 +1733,7 @@ struct ToRelativeQuarterNumImpl
static auto execute(Int32 d, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeQuarterNum(ExtendedDayNum(d)));
return time_zone.toRelativeQuarterNum(ExtendedDayNum(d));
else
return static_cast<UInt16>(time_zone.toRelativeQuarterNum(ExtendedDayNum(d)));
}
Expand All @@ -1754,7 +1754,7 @@ struct ToRelativeMonthNumImpl
static auto execute(Int64 t, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeMonthNum(t));
return time_zone.toRelativeMonthNum(t);
else
return static_cast<UInt16>(time_zone.toRelativeMonthNum(t));
}
Expand All @@ -1765,7 +1765,7 @@ struct ToRelativeMonthNumImpl
static auto execute(Int32 d, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeMonthNum(ExtendedDayNum(d)));
return time_zone.toRelativeMonthNum(ExtendedDayNum(d));
else
return static_cast<UInt16>(time_zone.toRelativeMonthNum(ExtendedDayNum(d)));
}
Expand All @@ -1786,7 +1786,7 @@ struct ToRelativeWeekNumImpl
static auto execute(Int64 t, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeWeekNum(t));
return time_zone.toRelativeWeekNum(t);
else
return static_cast<UInt16>(time_zone.toRelativeWeekNum(t));
}
Expand All @@ -1797,7 +1797,7 @@ struct ToRelativeWeekNumImpl
static auto execute(Int32 d, const DateLUTImpl & time_zone)
{
if constexpr (precision_ == ResultPrecision::Extended)
return static_cast<Int32>(time_zone.toRelativeWeekNum(ExtendedDayNum(d)));
return time_zone.toRelativeWeekNum(ExtendedDayNum(d));
else
return static_cast<UInt16>(time_zone.toRelativeWeekNum(ExtendedDayNum(d)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/FunctionFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class FunctionFile : public IFunction, WithContext

try
{
if (need_check && file_path.string().find(user_files_absolute_path_string) != 0)
if (need_check && !file_path.string().starts_with(user_files_absolute_path_string))
throw Exception(ErrorCodes::DATABASE_ACCESS_DENIED, "File is not inside {}", user_files_absolute_path.string());

ReadBufferFromFile in(file_path);
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/FunctionMathBinaryFloat64.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct BinaryFunctionVectorized
template <typename T1, typename T2>
static void execute(const T1 * src_left, const T2 * src_right, Float64 * dst)
{
dst[0] = static_cast<Float64>(Function(static_cast<Float64>(src_left[0]), static_cast<Float64>(src_right[0])));
dst[0] = Function(static_cast<Float64>(src_left[0]), static_cast<Float64>(src_right[0]));
}
};

Expand Down
3 changes: 1 addition & 2 deletions src/Functions/FunctionsConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ struct ToDateTimeImpl
}
else if constexpr (date_time_overflow_behavior == FormatSettings::DateTimeOverflowBehavior::Saturate)
{
if (d > MAX_DATETIME_DAY_NUM)
d = MAX_DATETIME_DAY_NUM;
d = std::min<time_t>(d, MAX_DATETIME_DAY_NUM);
}
return static_cast<UInt32>(time_zone.fromDayNum(DayNum(d)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/FunctionsHashing.h
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ struct URLHierarchyHashImpl
* (http, file - fit, mailto, magnet - do not fit), and after two slashes there is still something
* For the rest, simply return the full URL as the only element of the hierarchy.
*/
if (pos == begin || pos == end || !(*pos++ == ':' && pos < end && *pos++ == '/' && pos < end && *pos++ == '/' && pos < end))
if (pos == begin || pos == end || !(pos + 3 < end && pos[0] == ':' && pos[1] == '/' && pos[2] == '/'))
{
pos = end;
return 0 == level ? pos - begin : 0;
Expand Down
3 changes: 1 addition & 2 deletions src/Functions/FunctionsJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ class FunctionJSONHelpers
for (const auto i : collections::range(0, offsets.size()))
{
size_t size = offsets[i] - offsets[i - 1];
if (max_size < size)
max_size = size;
max_size = std::max(max_size, size);
}
if (max_size)
--max_size;
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/GeoHash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ inline Encoded merge(const Encoded & encodedLon, const Encoded & encodedLat, uin
Encoded result;
result.fill(0);

const auto bits = (precision * BITS_PER_SYMBOL) / 2;
uint8_t bits = (precision * BITS_PER_SYMBOL) / 2;
assert(bits < 255);
uint8_t i = 0;
for (; i < bits; ++i)
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/URL/URLHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class URLPathHierarchyImpl
* (http, file - fit, mailto, magnet - do not fit), and after two slashes still at least something is there.
* For the rest, just return an empty array.
*/
if (pos == begin || pos == end || !(*pos++ == ':' && pos < end && *pos++ == '/' && pos < end && *pos++ == '/' && pos < end))
if (pos == begin || pos == end || !(pos + 3 < end && pos[0] == ':' && pos[1] == '/' && pos[2] == '/'))
{
pos = end;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/castTypeToEither.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static bool castTypeToEither(const T * type, F && f)
template <class ...Args>
static bool castTypeToEither(TypeList<Args...>, const auto * type, auto && f)
{
return ((typeid_cast<const Args *>(type) != nullptr && std::forward<decltype(f)>(f)(*typeid_cast<const Args *>(type))) || ...);
return ((typeid_cast<const Args *>(type) != nullptr && f(*typeid_cast<const Args *>(type))) || ...);
}

}
9 changes: 4 additions & 5 deletions src/Functions/formatDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,12 @@ class FunctionFormatDateTimeImpl : public IFunction

static size_t jodaEra(size_t min_represent_digits, char * dest, Time source, UInt64, UInt32, const DateLUTImpl & timezone)
{
auto year = static_cast<Int32>(ToYearImpl::execute(source, timezone));
Int32 year = static_cast<Int32>(ToYearImpl::execute(source, timezone));
String res;
if (min_represent_digits <= 3)
res = static_cast<Int32>(year) > 0 ? "AD" : "BC";
res = year > 0 ? "AD" : "BC";
else
res = static_cast<Int32>(year) > 0 ? "Anno Domini" : "Before Christ";
res = year > 0 ? "Anno Domini" : "Before Christ";

memcpy(dest, res.data(), res.size());
return res.size();
Expand Down Expand Up @@ -689,8 +689,7 @@ class FunctionFormatDateTimeImpl : public IFunction

static size_t jodaFractionOfSecond(size_t min_represent_digits, char * dest, Time /*source*/, UInt64 fractional_second, UInt32 scale, const DateLUTImpl & /*timezone*/)
{
if (min_represent_digits > 9)
min_represent_digits = 9;
min_represent_digits = std::min<size_t>(min_represent_digits, 9);
if (fractional_second == 0)
{
for (UInt64 i = 0; i < min_represent_digits; ++i)
Expand Down

0 comments on commit ced5cc1

Please sign in to comment.