aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authordarkk <darkk@yandex-team.ru>2022-02-10 16:49:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:49 +0300
commitf772ca38c4a395b911129411c06b2074d69d826f (patch)
tree76717845f670ca68fd5ebb858eaaf9963032c74e /util
parentab4e3e6f0c4354283ce0375c811569c080cbfbc3 (diff)
downloadydb-f772ca38c4a395b911129411c06b2074d69d826f.tar.gz
Restoring authorship annotation for <darkk@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/datetime/parser.h2
-rw-r--r--util/datetime/parser.rl620
-rw-r--r--util/datetime/parser_ut.cpp54
-rw-r--r--util/draft/ip.h30
-rw-r--r--util/generic/refcount.h18
5 files changed, 62 insertions, 62 deletions
diff --git a/util/datetime/parser.h b/util/datetime/parser.h
index f0c1b4a0c7..4735d41c01 100644
--- a/util/datetime/parser.h
+++ b/util/datetime/parser.h
@@ -146,7 +146,7 @@ struct TDurationParser {
ui32 Dc;
i32 MultiplierPower; // 6 for seconds, 0 for microseconds, -3 for nanoseconds
- i32 Multiplier;
+ i32 Multiplier;
ui64 IntegerPart;
ui32 FractionPart;
ui32 FractionDigits;
diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6
index 931f09eae1..def64235a1 100644
--- a/util/datetime/parser.rl6
+++ b/util/datetime/parser.rl6
@@ -730,13 +730,13 @@ include DateTimeParserCommon;
multiplier
= '' # >{ MultiplierPower = 6; } # work around Ragel bugs
| 'w' @{ MultiplierPower = 6; Multiplier = 604800; }
- | 'd' @{ MultiplierPower = 6; Multiplier = 86400; }
- | 'h' @{ MultiplierPower = 6; Multiplier = 3600; }
- | 'm' @{ MultiplierPower = 6; Multiplier = 60; }
- | 's' @{ MultiplierPower = 6; Multiplier = 1; }
- | 'ms' @{ MultiplierPower = 3; Multiplier = 1; }
- | 'us' @{ MultiplierPower = 0; Multiplier = 1; }
- | 'ns' @{ MultiplierPower = -3; Multiplier = 1; }
+ | 'd' @{ MultiplierPower = 6; Multiplier = 86400; }
+ | 'h' @{ MultiplierPower = 6; Multiplier = 3600; }
+ | 'm' @{ MultiplierPower = 6; Multiplier = 60; }
+ | 's' @{ MultiplierPower = 6; Multiplier = 1; }
+ | 'ms' @{ MultiplierPower = 3; Multiplier = 1; }
+ | 'us' @{ MultiplierPower = 0; Multiplier = 1; }
+ | 'ns' @{ MultiplierPower = -3; Multiplier = 1; }
;
integer = int @{ IntegerPart = I; };
@@ -756,7 +756,7 @@ TDurationParser::TDurationParser()
, I(0)
, Dc(0)
, MultiplierPower(6)
- , Multiplier(1)
+ , Multiplier(1)
, IntegerPart(0)
, FractionPart(0)
, FractionDigits(0)
@@ -783,8 +783,8 @@ TDuration TDurationParser::GetResult(TDuration defaultValue) const {
if (cs < TDurationParser_first_final)
return defaultValue;
ui64 us = 0;
- us += Multiplier * DecPower(IntegerPart, MultiplierPower);
- us += Multiplier * DecPower(FractionPart, MultiplierPower - FractionDigits);
+ us += Multiplier * DecPower(IntegerPart, MultiplierPower);
+ us += Multiplier * DecPower(FractionPart, MultiplierPower - FractionDigits);
return TDuration::MicroSeconds(us);
}
diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp
index 61364af997..fe59b95452 100644
--- a/util/datetime/parser_ut.cpp
+++ b/util/datetime/parser_ut.cpp
@@ -573,38 +573,38 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
Y_UNIT_TEST_SUITE(TDurationParseTest) {
Y_UNIT_TEST(TestParse) {
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60 * 60 * 24 * 7), TDuration::Parse("1w"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(102), TDuration::Parse("1.7m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119400), TDuration::Parse("1.99m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119940), TDuration::Parse("1.999m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119994), TDuration::Parse("1.9999m"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(60), TDuration::Parse("1h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1.5h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(102), TDuration::Parse("1.7h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(7164), TDuration::Parse("1.99h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7196400), TDuration::Parse("1.999h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7199640), TDuration::Parse("1.9999h"));
-
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(102), TDuration::Parse("1.7m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119400), TDuration::Parse("1.99m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119940), TDuration::Parse("1.999m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119994), TDuration::Parse("1.9999m"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(60), TDuration::Parse("1h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1.5h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(102), TDuration::Parse("1.7h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(7164), TDuration::Parse("1.99h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7196400), TDuration::Parse("1.999h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7199640), TDuration::Parse("1.9999h"));
+
UNIT_ASSERT_EQUAL(TDuration::Minutes(15), TDuration::Parse("15m"));
UNIT_ASSERT_EQUAL(TDuration::Hours(10), TDuration::Parse("10h"));
UNIT_ASSERT_EQUAL(TDuration::Days(365), TDuration::Parse("365d"));
UNIT_ASSERT_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(24), TDuration::Parse("1d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(2448), TDuration::Parse("1.7d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(171936), TDuration::Parse("1.99d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172713600), TDuration::Parse("1.999d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172791360), TDuration::Parse("1.9999d"));
-
-#if 0 // not implemented
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1m30s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1h30m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1d12h"));
-#endif
-
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(24), TDuration::Parse("1d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(2448), TDuration::Parse("1.7d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(171936), TDuration::Parse("1.99d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172713600), TDuration::Parse("1.999d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172791360), TDuration::Parse("1.9999d"));
+
+#if 0 // not implemented
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1m30s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1h30m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1d12h"));
+#endif
+
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10s"));
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10.000s"));
UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(4), TDuration::Parse("0.000004s"));
diff --git a/util/draft/ip.h b/util/draft/ip.h
index eb947cd2cd..29e5da2146 100644
--- a/util/draft/ip.h
+++ b/util/draft/ip.h
@@ -30,10 +30,10 @@ struct TIp6 {
bool operator==(const TIp6& rhs) const {
return memcmp(Data, rhs.Data, sizeof(Data)) == 0;
}
-
- bool operator<(const TIp6& rhs) const {
- return memcmp(Data, rhs.Data, sizeof(Data)) < 0;
- }
+
+ bool operator<(const TIp6& rhs) const {
+ return memcmp(Data, rhs.Data, sizeof(Data)) < 0;
+ }
};
template <>
@@ -43,15 +43,15 @@ struct THash<TIp6> {
}
};
-static inline TIp6 Ip6FromIp4(TIp4 addr) {
- TIp6 res;
- memset(res.Data, 0, sizeof(res.Data));
+static inline TIp6 Ip6FromIp4(TIp4 addr) {
+ TIp6 res;
+ memset(res.Data, 0, sizeof(res.Data));
res.Data[10] = '\xFF';
res.Data[11] = '\xFF';
- memcpy(res.Data + 12, &addr, 4);
- return res;
-}
-
+ memcpy(res.Data + 12, &addr, 4);
+ return res;
+}
+
static inline TIp6 Ip6FromString(const char* ipStr) {
TIp6 res;
@@ -86,11 +86,11 @@ static inline TString Ip6ToString(const TIp6& ip) {
return TString(Ip6ToString(ip, buf, sizeof(buf)));
}
-template <>
+template <>
inline void Out<TIp6>(IOutputStream& os, const TIp6& a) {
- os << Ip6ToString(a);
-}
-
+ os << Ip6ToString(a);
+}
+
using TIp4Or6 = std::variant<TIp4, TIp6>;
static inline TIp4Or6 Ip4Or6FromString(const char* ipStr) {
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index 966e853b77..2f8ce6499a 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -89,17 +89,17 @@ using TSimpleCounter = TSimpleCounterTemplate<TCheckPolicy>;
// Use this one if you do want to share the pointer between threads, omit thread checks and do the synchronization yourself
using TExplicitSimpleCounter = TSimpleCounterTemplate<TNoCheckPolicy>;
-template <class TCounterCheckPolicy>
-struct TCommonLockOps<TSimpleCounterTemplate<TCounterCheckPolicy>> {
+template <class TCounterCheckPolicy>
+struct TCommonLockOps<TSimpleCounterTemplate<TCounterCheckPolicy>> {
static inline void Acquire(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
- t->Inc();
- }
-
+ t->Inc();
+ }
+
static inline void Release(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
- t->Dec();
- }
-};
-
+ t->Dec();
+ }
+};
+
class TAtomicCounter {
public:
inline TAtomicCounter(long initial = 0) noexcept