diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2022-02-10 16:45:40 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:40 +0300 |
commit | 5d50718e66d9c037dc587a0211110b7d25a66185 (patch) | |
tree | e98df59de24d2ef7c77baed9f41e4875a2fef972 /util/string | |
parent | a6a92afe03e02795227d2641b49819b687f088f8 (diff) | |
download | ydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz |
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/string')
-rw-r--r-- | util/string/benchmark/ascii/main.cpp | 70 | ||||
-rw-r--r-- | util/string/benchmark/float_to_string/metrics/main.py | 2 | ||||
-rw-r--r-- | util/string/benchmark/join/metrics/main.py | 2 | ||||
-rw-r--r-- | util/string/benchmark/subst_global/metrics/main.py | 2 | ||||
-rw-r--r-- | util/string/cast.h | 10 | ||||
-rw-r--r-- | util/string/cast.py | 4 | ||||
-rw-r--r-- | util/string/cast_ut.cpp | 28 |
7 files changed, 59 insertions, 59 deletions
diff --git a/util/string/benchmark/ascii/main.cpp b/util/string/benchmark/ascii/main.cpp index 49ad13228d..673047025d 100644 --- a/util/string/benchmark/ascii/main.cpp +++ b/util/string/benchmark/ascii/main.cpp @@ -17,20 +17,20 @@ namespace { return Get((ui8)x) ? x + ('a' - 'A') : x; } }; - - struct TToLowerLookup { - char Table[256]; - - TToLowerLookup() { - for (size_t i : xrange(256)) { - Table[i] = AsciiToLower(i); - } - } - - char ToLower(char x) const noexcept { - return Table[(ui8)x]; - } - }; + + struct TToLowerLookup { + char Table[256]; + + TToLowerLookup() { + for (size_t i : xrange(256)) { + Table[i] = AsciiToLower(i); + } + } + + char ToLower(char x) const noexcept { + return Table[(ui8)x]; + } + }; } static inline char FastAsciiToLower(char c) { @@ -91,27 +91,27 @@ Y_CPU_BENCHMARK(BitMapAsciiToLower, iface) { } } -Y_CPU_BENCHMARK(LookupAsciiToLower, iface) { - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - - for (int j = 0; j < 256; ++j) { - Y_DO_NOT_OPTIMIZE_AWAY(Singleton<TToLowerLookup>()->ToLower(j)); - } - } -} - -Y_CPU_BENCHMARK(LookupAsciiToLowerNoSingleton, iface) { - TToLowerLookup lookup; - for (const auto i : xrange(iface.Iterations())) { - Y_UNUSED(i); - - for (int j = 0; j < 256; ++j) { - Y_DO_NOT_OPTIMIZE_AWAY(lookup.ToLower(j)); - } - } -} - +Y_CPU_BENCHMARK(LookupAsciiToLower, iface) { + for (const auto i : xrange(iface.Iterations())) { + Y_UNUSED(i); + + for (int j = 0; j < 256; ++j) { + Y_DO_NOT_OPTIMIZE_AWAY(Singleton<TToLowerLookup>()->ToLower(j)); + } + } +} + +Y_CPU_BENCHMARK(LookupAsciiToLowerNoSingleton, iface) { + TToLowerLookup lookup; + for (const auto i : xrange(iface.Iterations())) { + Y_UNUSED(i); + + for (int j = 0; j < 256; ++j) { + Y_DO_NOT_OPTIMIZE_AWAY(lookup.ToLower(j)); + } + } +} + Y_CPU_BENCHMARK(tolower, iface) { for (const auto i : xrange(iface.Iterations())) { Y_UNUSED(i); diff --git a/util/string/benchmark/float_to_string/metrics/main.py b/util/string/benchmark/float_to_string/metrics/main.py index ec98b468e0..e9d4b7ac1d 100644 --- a/util/string/benchmark/float_to_string/metrics/main.py +++ b/util/string/benchmark/float_to_string/metrics/main.py @@ -2,4 +2,4 @@ import yatest.common as yc def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/float_to_string/float_to_string', threads=8)) + metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/float_to_string/float_to_string', threads=8)) diff --git a/util/string/benchmark/join/metrics/main.py b/util/string/benchmark/join/metrics/main.py index 876985d719..1ed5014808 100644 --- a/util/string/benchmark/join/metrics/main.py +++ b/util/string/benchmark/join/metrics/main.py @@ -2,4 +2,4 @@ import yatest.common as yc def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/join/join', threads=8)) + metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/join/join', threads=8)) diff --git a/util/string/benchmark/subst_global/metrics/main.py b/util/string/benchmark/subst_global/metrics/main.py index dcfc0e1307..62f2f3d76d 100644 --- a/util/string/benchmark/subst_global/metrics/main.py +++ b/util/string/benchmark/subst_global/metrics/main.py @@ -2,4 +2,4 @@ import yatest.common as yc def test_export_metrics(metrics): - metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/subst_global/subst_global', threads=8)) + metrics.set_benchmark(yc.execute_benchmark('util/string/benchmark/subst_global/subst_global', threads=8)) diff --git a/util/string/cast.h b/util/string/cast.h index 622c96aae7..90e925c194 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -323,14 +323,14 @@ inline TString IntToString(T t) { return TString(buf, IntToString<base>(t, buf, sizeof(buf))); } -template <int base, class TInt, class TChar> -bool TryIntFromString(const TChar* data, size_t len, TInt& result); - +template <int base, class TInt, class TChar> +bool TryIntFromString(const TChar* data, size_t len, TInt& result); + template <int base, class TInt, class TStringType> inline bool TryIntFromString(const TStringType& s, TInt& result) { return TryIntFromString<base>(s.data(), s.size(), result); -} - +} + template <class TInt, int base, class TChar> TInt IntFromString(const TChar* str, size_t len); diff --git a/util/string/cast.py b/util/string/cast.py index 47425494c0..4787f6ef44 100644 --- a/util/string/cast.py +++ b/util/string/cast.py @@ -1,6 +1,6 @@ print 'static const ui8 SAFE_LENS[4][15] = {' - + def nb(n, b): if n == 0: return [0] @@ -15,7 +15,7 @@ def nb(n, b): for p in (1, 2, 4, 8): - + def it1(): for base in range(2, 17): m = 2 ** (8 * p) - 1 diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index c861add9bf..033450c38c 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -24,22 +24,22 @@ #define OK_HEX_CHECK(type, val, base) UNIT_ASSERT_EQUAL((IntFromStringForCheck<base>(IntToString<base>(val))), val); #define EXC_HEX_CHECK(type, val, base) UNIT_ASSERT_EXCEPTION((IntFromString<type, base>(IntToString<base>(val))), yexception); -#define TRY_HEX_MACROS_MAP(mac, type, val, result, def) \ +#define TRY_HEX_MACROS_MAP(mac, type, val, result, def) \ mac(type, val, result, def, 2) \ mac(type, val, result, def, 8) \ mac(type, val, result, def, 10) \ mac(type, val, result, def, 16) - + #define TRY_OK_HEX_CHECK(type, val, result, def, base) \ result = def; \ - UNIT_ASSERT_EQUAL(TryIntFromStringForCheck<base>(IntToString<base>(val), result), true); \ - UNIT_ASSERT_EQUAL(result, val); - + UNIT_ASSERT_EQUAL(TryIntFromStringForCheck<base>(IntToString<base>(val), result), true); \ + UNIT_ASSERT_EQUAL(result, val); + #define TRY_FAIL_HEX_CHECK(type, val, result, def, base) \ result = def; \ UNIT_ASSERT_VALUES_EQUAL(TryIntFromStringForCheck<base>(IntToString<base>(val), result), false); \ UNIT_ASSERT_VALUES_EQUAL(result, def); - + template <class A> struct TRet { template <int base> @@ -47,11 +47,11 @@ struct TRet { return IntFromString<A, base>(str); } - template <int base> + template <int base> inline bool TryIntFromStringForCheck(const TString& str, A& result) { - return TryIntFromString<base>(str, result); - } - + return TryIntFromString<base>(str, result); + } + template <class B> inline void CheckOK(B v) { UNIT_ASSERT_VALUES_EQUAL(FromString<A>(ToString(v)), v); // char @@ -68,14 +68,14 @@ struct TRet { template <class B> inline void CheckTryOK(B v) { - static const A defaultV = 42; + static const A defaultV = 42; A convV; UNIT_ASSERT_VALUES_EQUAL(TryFromString<A>(ToString(v), convV), true); // char UNIT_ASSERT_VALUES_EQUAL(v, convV); UNIT_ASSERT_VALUES_EQUAL(TryFromString<A>(ToWtring(v), convV), true); // wide char UNIT_ASSERT_VALUES_EQUAL(v, convV); - TRY_HEX_MACROS_MAP(TRY_OK_HEX_CHECK, A, v, convV, defaultV); + TRY_HEX_MACROS_MAP(TRY_OK_HEX_CHECK, A, v, convV, defaultV); } template <class B> @@ -86,8 +86,8 @@ struct TRet { UNIT_ASSERT_VALUES_EQUAL(defaultV, convV); UNIT_ASSERT_VALUES_EQUAL(TryFromString<A>(ToWtring(v), convV), false); // wide char UNIT_ASSERT_VALUES_EQUAL(defaultV, convV); - - TRY_HEX_MACROS_MAP(TRY_FAIL_HEX_CHECK, A, v, convV, defaultV); + + TRY_HEX_MACROS_MAP(TRY_FAIL_HEX_CHECK, A, v, convV, defaultV); } }; |