aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:45 +0300
commit9123176b341b6f2658cff5132482b8237c1416c8 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util
parent59e19371de37995fcb36beb16cd6ec030af960bc (diff)
downloadydb-9123176b341b6f2658cff5132482b8237c1416c8.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/recode_result.h2
-rw-r--r--util/charset/unidata.h2
-rw-r--r--util/charset/wide.h32
-rw-r--r--util/charset/wide_ut.cpp2
-rw-r--r--util/datetime/base.h2
-rw-r--r--util/datetime/cputimer.h2
-rw-r--r--util/datetime/parser.h2
-rw-r--r--util/datetime/systime.h2
-rw-r--r--util/digest/fnv.h2
-rw-r--r--util/digest/murmur.h2
-rw-r--r--util/digest/numeric.h6
-rw-r--r--util/draft/date.h6
-rw-r--r--util/draft/datetime.cpp232
-rw-r--r--util/draft/datetime.h150
-rw-r--r--util/draft/datetime_ut.cpp368
-rw-r--r--util/draft/enum.h2
-rw-r--r--util/draft/holder_vector.h2
-rw-r--r--util/draft/matrix.h2
-rw-r--r--util/draft/ya.make2
-rw-r--r--util/folder/dirent_win.h2
-rw-r--r--util/folder/dirut.cpp2
-rw-r--r--util/folder/dirut.h4
-rw-r--r--util/folder/filelist.h2
-rw-r--r--util/folder/iterator.h2
-rw-r--r--util/folder/lstat_win.h2
-rw-r--r--util/folder/path.cpp40
-rw-r--r--util/folder/path.h10
-rw-r--r--util/generic/algorithm.h32
-rw-r--r--util/generic/algorithm_ut.cpp16
-rw-r--r--util/generic/bitmap.h2
-rw-r--r--util/generic/bitops.h2
-rw-r--r--util/generic/buffer.h8
-rw-r--r--util/generic/cast.h2
-rw-r--r--util/generic/deque.h2
-rw-r--r--util/generic/hash.h4
-rw-r--r--util/generic/intrlist.h2
-rw-r--r--util/generic/iterator.h2
-rw-r--r--util/generic/list.h2
-rw-r--r--util/generic/map.h2
-rw-r--r--util/generic/map_ut.cpp16
-rw-r--r--util/generic/maybe.h2
-rw-r--r--util/generic/maybe_ut.cpp20
-rw-r--r--util/generic/noncopyable.h20
-rw-r--r--util/generic/ptr.h8
-rw-r--r--util/generic/refcount.h2
-rw-r--r--util/generic/set.h2
-rw-r--r--util/generic/singleton.h2
-rw-r--r--util/generic/stack.h2
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/strbuf.h6
-rw-r--r--util/generic/strfcpy.h2
-rw-r--r--util/generic/string.h2
-rw-r--r--util/generic/typelist.h2
-rw-r--r--util/generic/typetraits.h2
-rw-r--r--util/generic/utility.h2
-rw-r--r--util/generic/variant.h12
-rw-r--r--util/generic/vector.h2
-rw-r--r--util/generic/yexception.h4
-rw-r--r--util/generic/yexception_ut.h2
-rw-r--r--util/generic/ylimits.h2
-rw-r--r--util/generic/ymath.h2
-rw-r--r--util/generic/ymath_ut.cpp2
-rw-r--r--util/memory/addstorage.h2
-rw-r--r--util/memory/alloc.h2
-rw-r--r--util/memory/blob.h2
-rw-r--r--util/memory/mmapalloc.h2
-rw-r--r--util/memory/pool.h32
-rw-r--r--util/memory/pool_ut.cpp18
-rw-r--r--util/memory/segmented_string_pool.h2
-rw-r--r--util/memory/segpool_alloc.h2
-rw-r--r--util/memory/smallobj.h50
-rw-r--r--util/memory/smallobj_ut.cpp28
-rw-r--r--util/memory/tempbuf.h2
-rw-r--r--util/network/address.cpp40
-rw-r--r--util/network/hostip.h2
-rw-r--r--util/network/init.h2
-rw-r--r--util/network/iovec.h2
-rw-r--r--util/network/ip.h2
-rw-r--r--util/network/nonblock.h2
-rw-r--r--util/network/pair.h2
-rw-r--r--util/network/poller.h2
-rw-r--r--util/network/pollerimpl.h2
-rw-r--r--util/network/sock.h2
-rw-r--r--util/network/socket.h2
-rw-r--r--util/random/entropy.h2
-rw-r--r--util/random/mersenne.h2
-rw-r--r--util/random/mersenne32.h2
-rw-r--r--util/random/mersenne64.h2
-rw-r--r--util/random/random.h8
-rw-r--r--util/random/shuffle.h12
-rw-r--r--util/random/shuffle_ut.cpp20
-rw-r--r--util/str_stl.h4
-rw-r--r--util/stream/aligned.h2
-rw-r--r--util/stream/buffer.h2
-rw-r--r--util/stream/buffered.h2
-rw-r--r--util/stream/debug.h2
-rw-r--r--util/stream/file.h2
-rw-r--r--util/stream/format.h2
-rw-r--r--util/stream/input.cpp10
-rw-r--r--util/stream/input.h2
-rw-r--r--util/stream/length.cpp58
-rw-r--r--util/stream/length.h40
-rw-r--r--util/stream/mem.h2
-rw-r--r--util/stream/multi.h2
-rw-r--r--util/stream/null.h2
-rw-r--r--util/stream/output.h2
-rw-r--r--util/stream/pipe.h2
-rw-r--r--util/stream/printf.h2
-rw-r--r--util/stream/str.h2
-rw-r--r--util/stream/tee.h2
-rw-r--r--util/stream/tempbuf.h2
-rw-r--r--util/stream/tokenizer.h2
-rw-r--r--util/stream/walk.h2
-rw-r--r--util/stream/zerocopy.h2
-rw-r--r--util/stream/zlib.h2
-rw-r--r--util/string/cast.h4
-rw-r--r--util/string/escape.cpp80
-rw-r--r--util/string/escape.h38
-rw-r--r--util/string/escape_ut.cpp2
-rw-r--r--util/string/hex.h2
-rw-r--r--util/string/split.h2
-rw-r--r--util/string/subst_ut.cpp180
-rw-r--r--util/string/type_ut.cpp4
-rw-r--r--util/string/util.h4
-rw-r--r--util/string/vector.h2
-rw-r--r--util/system/align.h2
-rw-r--r--util/system/atexit.h2
-rw-r--r--util/system/atomic.h2
-rw-r--r--util/system/atomic_gcc.h2
-rw-r--r--util/system/atomic_win.h2
-rw-r--r--util/system/backtrace.h2
-rw-r--r--util/system/byteorder.h2
-rw-r--r--util/system/compat.h2
-rw-r--r--util/system/condvar.h2
-rw-r--r--util/system/context.h2
-rw-r--r--util/system/context_i686.h2
-rw-r--r--util/system/context_x86.h2
-rw-r--r--util/system/context_x86_64.h2
-rw-r--r--util/system/daemon.h2
-rw-r--r--util/system/datetime.h2
-rw-r--r--util/system/defaults.h2
-rw-r--r--util/system/dynlib.h2
-rw-r--r--util/system/error.h2
-rw-r--r--util/system/event.h2
-rw-r--r--util/system/execpath.h2
-rw-r--r--util/system/fasttime.cpp382
-rw-r--r--util/system/fasttime.h12
-rw-r--r--util/system/file.cpp8
-rw-r--r--util/system/file.h2
-rw-r--r--util/system/filemap.cpp10
-rw-r--r--util/system/filemap.h2
-rw-r--r--util/system/flock.h2
-rw-r--r--util/system/fs.h2
-rw-r--r--util/system/fstat.cpp144
-rw-r--r--util/system/fstat.h26
-rw-r--r--util/system/guard.h2
-rw-r--r--util/system/hostname.h2
-rw-r--r--util/system/hp_timer.h4
-rw-r--r--util/system/info.h2
-rw-r--r--util/system/madvise.cpp62
-rw-r--r--util/system/madvise.h24
-rw-r--r--util/system/maxlen.h2
-rw-r--r--util/system/mem_info.cpp46
-rw-r--r--util/system/mem_info.h14
-rw-r--r--util/system/mem_info_ut.cpp28
-rw-r--r--util/system/mutex.h2
-rw-r--r--util/system/pipe.h2
-rw-r--r--util/system/platform.h2
-rw-r--r--util/system/progname.h2
-rw-r--r--util/system/rwlock.h2
-rw-r--r--util/system/sem.h2
-rw-r--r--util/system/sigset.h2
-rw-r--r--util/system/spin_wait.h2
-rw-r--r--util/system/spinlock.h2
-rw-r--r--util/system/sys_alloc.h2
-rw-r--r--util/system/tempfile.h2
-rw-r--r--util/system/thread.h2
-rw-r--r--util/system/tls.h2
-rw-r--r--util/system/type_name.h2
-rw-r--r--util/system/valgrind.h2
-rw-r--r--util/system/yassert.h2
-rw-r--r--util/system/yield.h2
-rw-r--r--util/thread/factory.h2
-rw-r--r--util/thread/lfqueue.h2
-rw-r--r--util/thread/lfstack.h2
-rw-r--r--util/thread/pool.h2
-rw-r--r--util/ysafeptr.h4
-rw-r--r--util/ysaveload.h2
188 files changed, 1331 insertions, 1331 deletions
diff --git a/util/charset/recode_result.h b/util/charset/recode_result.h
index 2f5cc86634..2c7366e7b2 100644
--- a/util/charset/recode_result.h
+++ b/util/charset/recode_result.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
enum RECODE_RESULT {
RECODE_OK,
diff --git a/util/charset/unidata.h b/util/charset/unidata.h
index 9bd48fe4c5..400d314186 100644
--- a/util/charset/unidata.h
+++ b/util/charset/unidata.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "unicode_table.h"
diff --git a/util/charset/wide.h b/util/charset/wide.h
index 6470fd0172..04e6928aab 100644
--- a/util/charset/wide.h
+++ b/util/charset/wide.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "recode_result.h"
#include "unidata.h"
@@ -298,7 +298,7 @@ namespace NDetail {
void UTF8ToWideImplSSE41(const unsigned char*& cur, const unsigned char* last, wchar32*& dest) noexcept;
}
-//! @return len if robust and position where encoding stopped if not
+//! @return len if robust and position where encoding stopped if not
template <bool robust, typename TCharType>
inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size_t& written) noexcept {
const unsigned char* cur = reinterpret_cast<const unsigned char*>(text);
@@ -309,7 +309,7 @@ inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size
::NDetail::UTF8ToWideImplSSE41(cur, last, p);
}
#endif
-
+
::NDetail::UTF8ToWideImplScalar<robust>(cur, last, p);
written = p - dest;
return cur - reinterpret_cast<const unsigned char*>(text);
@@ -317,9 +317,9 @@ inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size
template <typename TCharType>
inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size_t& written) {
- return UTF8ToWideImpl<false>(text, len, dest, written);
-}
-
+ return UTF8ToWideImpl<false>(text, len, dest, written);
+}
+
template <bool robust>
inline TUtf16String UTF8ToWide(const char* text, size_t len) {
TUtf16String w = TUtf16String::Uninitialized(len);
@@ -334,19 +334,19 @@ inline TUtf16String UTF8ToWide(const char* text, size_t len) {
template <bool robust, typename TCharType>
inline bool UTF8ToWide(const char* text, size_t len, TCharType* dest, size_t& written) noexcept {
- return UTF8ToWideImpl<robust>(text, len, dest, written) == len;
-}
-
+ return UTF8ToWideImpl<robust>(text, len, dest, written) == len;
+}
+
//! converts text from UTF8 to unicode, stops immediately it UTF8 byte sequence is wrong
//! @attention destination buffer must be long enough to fit all characters of the text,
//! conversion stops if a broken symbol is met
//! @return @c true if all the text converted successfully, @c false - a broken symbol was found
template <typename TCharType>
inline bool UTF8ToWide(const char* text, size_t len, TCharType* dest, size_t& written) noexcept {
- return UTF8ToWide<false>(text, len, dest, written);
+ return UTF8ToWide<false>(text, len, dest, written);
}
-template <bool robust>
+template <bool robust>
inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
dst.ReserveAndResize(src.size());
size_t written = 0;
@@ -367,17 +367,17 @@ inline TUtf32StringBuf UTF8ToUTF32(const TStringBuf src, TUtf32String& dst) {
inline TWtringBuf UTF8ToWide(const TStringBuf src, TUtf16String& dst) {
return UTF8ToWide<false>(src, dst);
-}
-
+}
+
inline TUtf16String UTF8ToWide(const char* text, size_t len) {
return UTF8ToWide<false>(text, len);
}
-template <bool robust>
+template <bool robust>
inline TUtf16String UTF8ToWide(const TStringBuf s) {
return UTF8ToWide<robust>(s.data(), s.size());
-}
-
+}
+
template <bool robust>
inline TUtf32String UTF8ToUTF32(const TStringBuf s) {
TUtf32String r;
diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp
index bf06cf2b5c..d8f3233e73 100644
--- a/util/charset/wide_ut.cpp
+++ b/util/charset/wide_ut.cpp
@@ -509,7 +509,7 @@ void TConversionTest::TestUTF8ToWide() {
wchar16 wNonBMPDummy2[] = {'a', 'b', 0xDBC0, 0xDE47, 'n'};
TestSurrogates(utf8NonBMP2, wNonBMPDummy2, Y_ARRAY_SIZE(wNonBMPDummy2));
- UNIT_ASSERT_VALUES_EQUAL(WideToUTF8(UTF8ToWide(WideToUTF8(UTF8ToWide<true>(
+ UNIT_ASSERT_VALUES_EQUAL(WideToUTF8(UTF8ToWide(WideToUTF8(UTF8ToWide<true>(
"m\xFB\xB2\xA5\xAA\xAFyeuse.sexwebcamz.com")))),
TString(
"m\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBDyeuse.sexwebcamz.com"));
diff --git a/util/datetime/base.h b/util/datetime/base.h
index ce0b4e77ac..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "systime.h"
diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h
index 95ef4ba93d..7d38d5bdb3 100644
--- a/util/datetime/cputimer.h
+++ b/util/datetime/cputimer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "base.h"
diff --git a/util/datetime/parser.h b/util/datetime/parser.h
index 498324f0b0..f0c1b4a0c7 100644
--- a/util/datetime/parser.h
+++ b/util/datetime/parser.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// probably you do not need to include this file directly, use "util/datetime/base.h"
diff --git a/util/datetime/systime.h b/util/datetime/systime.h
index 6222d985cc..491d36e802 100644
--- a/util/datetime/systime.h
+++ b/util/datetime/systime.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/platform.h>
#include <util/generic/string.h>
diff --git a/util/digest/fnv.h b/util/digest/fnv.h
index 7326fb2c0a..87b41a3de7 100644
--- a/util/digest/fnv.h
+++ b/util/digest/fnv.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
diff --git a/util/digest/murmur.h b/util/digest/murmur.h
index ba78cc5698..6b519b430a 100644
--- a/util/digest/murmur.h
+++ b/util/digest/murmur.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
#include <util/generic/array_ref.h>
diff --git a/util/digest/numeric.h b/util/digest/numeric.h
index 512018b3de..e20bd908e4 100644
--- a/util/digest/numeric.h
+++ b/util/digest/numeric.h
@@ -1,11 +1,11 @@
-#pragma once
+#pragma once
#include <util/generic/typelist.h>
#include <util/system/defaults.h>
/*
- * original url (now dead): http://www.cris.com/~Ttwang/tech/inthash.htm
- * copy: https://gist.github.com/badboy/6267743
+ * original url (now dead): http://www.cris.com/~Ttwang/tech/inthash.htm
+ * copy: https://gist.github.com/badboy/6267743
*/
static constexpr ui8 IntHashImpl(ui8 key8) noexcept {
diff --git a/util/draft/date.h b/util/draft/date.h
index 4f7942ed79..e3eb616fe5 100644
--- a/util/draft/date.h
+++ b/util/draft/date.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/stream/output.h>
#include <util/stream/input.h>
@@ -7,8 +7,8 @@
#include <ctime>
-// XXX: uses system calls for trivial things. may be very slow therefore.
-
+// XXX: uses system calls for trivial things. may be very slow therefore.
+
time_t GetDateStart(time_t ts);
// Local date (without time zone)
diff --git a/util/draft/datetime.cpp b/util/draft/datetime.cpp
index 401d6eda1e..5cbe7d8847 100644
--- a/util/draft/datetime.cpp
+++ b/util/draft/datetime.cpp
@@ -1,27 +1,27 @@
-#include "datetime.h"
-
+#include "datetime.h"
+
#include <util/ysaveload.h>
-#include <util/system/atomic.h>
-#include <util/system/fasttime.h>
-#include <util/datetime/base.h>
-#include <util/datetime/systime.h>
+#include <util/system/atomic.h>
+#include <util/system/fasttime.h>
+#include <util/datetime/base.h>
+#include <util/datetime/systime.h>
#include <util/stream/output.h>
#include <util/stream/mem.h>
#include <util/string/cast.h>
#include <util/string/printf.h>
-
-namespace NDatetime {
- const ui32 MonthDays[2][12] = {
+
+namespace NDatetime {
+ const ui32 MonthDays[2][12] = {
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, //nleap
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} //leap
- };
-
+ };
+
const ui32 MonthDaysNewYear[2][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, //nleap
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} //leap
- };
-
+ };
+
void YDayToMonthAndDay(ui32 yday, bool isleap, ui32* month, ui32* mday) {
const ui32* begin = MonthDaysNewYear[isleap] + 1;
const ui32* end = begin + 12;
@@ -36,60 +36,60 @@ namespace NDatetime {
Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month]));
}
- struct TTimeData {
- i32 IsDst = 0;
- i32 GMTOff = 0;
-
- TTimeData(time_t t) {
- struct ::tm tt;
- ::localtime_r(&t, &tt);
-#ifndef _win_
- GMTOff = tt.tm_gmtoff;
+ struct TTimeData {
+ i32 IsDst = 0;
+ i32 GMTOff = 0;
+
+ TTimeData(time_t t) {
+ struct ::tm tt;
+ ::localtime_r(&t, &tt);
+#ifndef _win_
+ GMTOff = tt.tm_gmtoff;
#else
- TIME_ZONE_INFORMATION tz;
- switch (GetTimeZoneInformation(&tz)) {
- case TIME_ZONE_ID_UNKNOWN:
- GMTOff = tz.Bias * -60;
- break;
- case TIME_ZONE_ID_STANDARD:
- GMTOff = (tz.Bias + tz.StandardBias) * -60;
- break;
- case TIME_ZONE_ID_DAYLIGHT:
- GMTOff = (tz.Bias + tz.DaylightBias) * -60;
- break;
- default:
- break;
- }
+ TIME_ZONE_INFORMATION tz;
+ switch (GetTimeZoneInformation(&tz)) {
+ case TIME_ZONE_ID_UNKNOWN:
+ GMTOff = tz.Bias * -60;
+ break;
+ case TIME_ZONE_ID_STANDARD:
+ GMTOff = (tz.Bias + tz.StandardBias) * -60;
+ break;
+ case TIME_ZONE_ID_DAYLIGHT:
+ GMTOff = (tz.Bias + tz.DaylightBias) * -60;
+ break;
+ default:
+ break;
+ }
#endif
- IsDst = tt.tm_isdst;
+ IsDst = tt.tm_isdst;
}
};
- TSimpleTM TSimpleTM::CurrentUTC() {
- return New((time_t)TInstant::MicroSeconds(InterpolatedMicroSeconds()).Seconds());
- }
-
- TSimpleTM TSimpleTM::New(time_t t, i32 gmtoff, i8 isdst) {
- time_t tt = t + gmtoff + isdst * 3600;
- struct tm tmSys;
- Zero(tmSys);
- GmTimeR(&tt, &tmSys);
- tmSys.tm_isdst = isdst;
-#ifndef _win_
- tmSys.tm_gmtoff = gmtoff;
-#endif
-
- return New(tmSys);
+ TSimpleTM TSimpleTM::CurrentUTC() {
+ return New((time_t)TInstant::MicroSeconds(InterpolatedMicroSeconds()).Seconds());
}
-
- TSimpleTM TSimpleTM::NewLocal(time_t t) {
- TTimeData d(t);
- return New(t, d.GMTOff, d.IsDst);
+
+ TSimpleTM TSimpleTM::New(time_t t, i32 gmtoff, i8 isdst) {
+ time_t tt = t + gmtoff + isdst * 3600;
+ struct tm tmSys;
+ Zero(tmSys);
+ GmTimeR(&tt, &tmSys);
+ tmSys.tm_isdst = isdst;
+#ifndef _win_
+ tmSys.tm_gmtoff = gmtoff;
+#endif
+
+ return New(tmSys);
+ }
+
+ TSimpleTM TSimpleTM::NewLocal(time_t t) {
+ TTimeData d(t);
+ return New(t, d.GMTOff, d.IsDst);
}
-
+
TSimpleTM TSimpleTM::New(const struct tm& t) {
TSimpleTM res;
- res.IsDst = t.tm_isdst;
+ res.IsDst = t.tm_isdst;
res.Sec = t.tm_sec;
res.Min = t.tm_min;
res.Hour = t.tm_hour;
@@ -98,39 +98,39 @@ namespace NDatetime {
res.MDay = t.tm_mday;
res.Year = t.tm_year;
res.YDay = t.tm_yday;
- res.IsLeap = LeapYearAD(res.Year + 1900);
-#ifndef _win_
+ res.IsLeap = LeapYearAD(res.Year + 1900);
+#ifndef _win_
res.GMTOff = t.tm_gmtoff;
-#endif
+#endif
return res;
}
-
- TSimpleTM& TSimpleTM::SetRealDate(ui32 year, ui32 mon, ui32 mday, ui32 hour, ui32 min, ui32 sec, i32 isdst) {
- mday = ::Max<ui32>(mday, 1);
- mon = ::Min<ui32>(::Max<ui32>(mon, 1), 12);
- year = ::Max<ui32>(year, 1900);
-
- IsLeap = LeapYearAD(year);
- Year = year - 1900;
- Mon = mon - 1;
- MDay = ::Min<ui32>(mday, MonthDays[IsLeap][Mon]);
- Hour = Max<ui32>() == hour ? Hour : ::Min<ui32>(hour, 23);
- Min = Max<ui32>() == min ? Min : ::Min<ui32>(min, 59);
- Sec = Max<ui32>() == sec ? Sec : ::Min<ui32>(sec, 60);
- IsDst = isdst;
-
- return RegenerateFields();
- }
-
- TSimpleTM& TSimpleTM::RegenerateFields() {
+
+ TSimpleTM& TSimpleTM::SetRealDate(ui32 year, ui32 mon, ui32 mday, ui32 hour, ui32 min, ui32 sec, i32 isdst) {
+ mday = ::Max<ui32>(mday, 1);
+ mon = ::Min<ui32>(::Max<ui32>(mon, 1), 12);
+ year = ::Max<ui32>(year, 1900);
+
+ IsLeap = LeapYearAD(year);
+ Year = year - 1900;
+ Mon = mon - 1;
+ MDay = ::Min<ui32>(mday, MonthDays[IsLeap][Mon]);
+ Hour = Max<ui32>() == hour ? Hour : ::Min<ui32>(hour, 23);
+ Min = Max<ui32>() == min ? Min : ::Min<ui32>(min, 59);
+ Sec = Max<ui32>() == sec ? Sec : ::Min<ui32>(sec, 60);
+ IsDst = isdst;
+
+ return RegenerateFields();
+ }
+
+ TSimpleTM& TSimpleTM::RegenerateFields() {
return *this = New(AsTimeT(), GMTOff, IsDst);
- }
-
+ }
+
TSimpleTM& TSimpleTM::Add(EField f, i32 amount) {
if (!amount) {
return *this;
}
-
+
switch (f) {
default:
return *this;
@@ -143,59 +143,59 @@ namespace NDatetime {
case F_MIN:
amount *= 60;
[[fallthrough]];
- case F_SEC: {
+ case F_SEC: {
return *this = New(AsTimeT() + amount, GMTOff, IsDst);
- }
+ }
case F_YEAR: {
i32 y = amount + (i32)Year;
y = ::Min<i32>(Max<i32>(y, 0), 255 /*max year*/);
-
+
// YDay may correspond to different MDay if it's March or greater and the years have different leap status
if (Mon > 1) {
- YDay += (i32)LeapYearAD(RealYear()) - (i32)LeapYearAD(RealYear());
+ YDay += (i32)LeapYearAD(RealYear()) - (i32)LeapYearAD(RealYear());
}
-
+
Year = y;
- IsLeap = LeapYearAD(RealYear());
- return RegenerateFields();
+ IsLeap = LeapYearAD(RealYear());
+ return RegenerateFields();
}
case F_MON: {
i32 m = amount + Mon;
i32 y = (m < 0 ? (-12 + m) : m) / 12;
m = m - y * 12;
-
- if (y) {
+
+ if (y) {
Add(F_YEAR, y);
- }
-
+ }
+
if (m >= 0 && m < 12) {
MDay = ::Min<ui32>(MonthDays[IsLeap][m], MDay);
- Mon = m;
+ Mon = m;
}
- return RegenerateFields();
+ return RegenerateFields();
}
- }
- }
+ }
+ }
TString TSimpleTM::ToString(const char* fmt) const {
struct tm t = *this;
- return Strftime(fmt, &t);
- }
-
- time_t TSimpleTM::AsTimeT() const {
- struct tm t = AsStructTmLocal();
- return TimeGM(&t) - GMTOff - IsDst * 3600;
+ return Strftime(fmt, &t);
}
-
- struct tm TSimpleTM::AsStructTmUTC() const {
- struct tm res;
- Zero(res);
- time_t t = AsTimeT();
- return *GmTimeR(&t, &res);
- }
-
- struct tm TSimpleTM::AsStructTmLocal() const {
+
+ time_t TSimpleTM::AsTimeT() const {
+ struct tm t = AsStructTmLocal();
+ return TimeGM(&t) - GMTOff - IsDst * 3600;
+ }
+
+ struct tm TSimpleTM::AsStructTmUTC() const {
+ struct tm res;
+ Zero(res);
+ time_t t = AsTimeT();
+ return *GmTimeR(&t, &res);
+ }
+
+ struct tm TSimpleTM::AsStructTmLocal() const {
struct tm t;
Zero(t);
t.tm_isdst = IsDst;
@@ -207,12 +207,12 @@ namespace NDatetime {
t.tm_mday = MDay;
t.tm_year = Year;
t.tm_yday = YDay;
-#ifndef _win_
+#ifndef _win_
t.tm_gmtoff = GMTOff;
-#endif
+#endif
return t;
}
-}
+}
template <>
void In<TMonth>(IInputStream& in, TMonth& t) {
diff --git a/util/draft/datetime.h b/util/draft/datetime.h
index 58a64b16ee..8a387ea6f1 100644
--- a/util/draft/datetime.h
+++ b/util/draft/datetime.h
@@ -1,32 +1,32 @@
-#pragma once
-
-#include <util/generic/algorithm.h>
+#pragma once
+
+#include <util/generic/algorithm.h>
#include <util/generic/string.h>
-#include <util/generic/yexception.h>
+#include <util/generic/yexception.h>
#include <util/generic/ymath.h>
#include <util/datetime/base.h>
-
+
#include <cstdlib>
#include <time.h>
-namespace NDatetime {
+namespace NDatetime {
extern const ui32 MonthDays[2][12]; // !leapYear; !!leapYear
extern const ui32 MonthDaysNewYear[2][13]; // !leapYear; !!leapYear
-
+
inline ui32 YearDaysAD(ui32 year) {
year = Max<ui32>(year, 1) - 1; //1 AD comes straight after 1 BC, no 0 AD
return year * 365 + year / 4 - year / 100 + year / 400;
}
-
+
inline bool LeapYearAD(ui32 year) {
- return (!(year % 4) && (year % 100)) || !(year % 400);
+ return (!(year % 4) && (year % 100)) || !(year % 400);
}
-
+
inline ui32 YDayFromMonthAndDay(ui32 month /*0 - based*/, ui32 mday /*1 - based*/, bool isleap) {
return MonthDaysNewYear[isleap][Min(month, (ui32)11u)] + mday - 1;
}
-
+
void YDayToMonthAndDay(ui32 yday /*0 - based*/, bool isleap, ui32* month /*0 - based*/, ui32* mday /*1 - based*/);
struct TSimpleTM {
@@ -39,111 +39,111 @@ namespace NDatetime {
F_MON,
F_YEAR
};
-
- i32 GMTOff = 0; // -43200 - 50400 seconds
- ui16 Year = 0; // from 1900
- ui16 YDay = 0; // 0-365
- ui8 Mon = 0; // 0-11
- ui8 MDay = 0; // 1-31
- ui8 WDay = 0; // 0-6
- ui8 Hour = 0; // 0-23
- ui8 Min = 0; // 0-59
- ui8 Sec = 0; // 0-60 - doesn't care for leap seconds. Most of the time it's ok.
- i8 IsDst = 0; // -1/0/1
- bool IsLeap = false;
-
- public:
- static TSimpleTM New(time_t t = 0, i32 gmtoff = 0, i8 isdst = 0);
- static TSimpleTM NewLocal(time_t = 0);
-
+
+ i32 GMTOff = 0; // -43200 - 50400 seconds
+ ui16 Year = 0; // from 1900
+ ui16 YDay = 0; // 0-365
+ ui8 Mon = 0; // 0-11
+ ui8 MDay = 0; // 1-31
+ ui8 WDay = 0; // 0-6
+ ui8 Hour = 0; // 0-23
+ ui8 Min = 0; // 0-59
+ ui8 Sec = 0; // 0-60 - doesn't care for leap seconds. Most of the time it's ok.
+ i8 IsDst = 0; // -1/0/1
+ bool IsLeap = false;
+
+ public:
+ static TSimpleTM New(time_t t = 0, i32 gmtoff = 0, i8 isdst = 0);
+ static TSimpleTM NewLocal(time_t = 0);
+
static TSimpleTM New(const struct tm&);
-
- static TSimpleTM CurrentUTC();
-
- TSimpleTM() = default;
-
+
+ static TSimpleTM CurrentUTC();
+
+ TSimpleTM() = default;
+
TSimpleTM(ui32 year, ui32 mon, ui32 day, ui32 h = 0, ui32 m = 0, ui32 s = 0) {
Zero(*this);
SetRealDate(year, mon, day, h, m, s);
}
-
+
// keeps the object consistent
TSimpleTM& Add(EField f, i32 amount = 1);
-
+
TString ToString(const char* fmt = "%a, %d %b %Y %H:%M:%S %z") const;
-
- TSimpleTM& ToUTC() {
+
+ TSimpleTM& ToUTC() {
return *this = New(AsTimeT());
- }
-
- bool IsUTC() const {
- return !IsDst && !GMTOff;
- }
-
- time_t AsTimeT() const;
-
- operator time_t() const {
- return AsTimeT();
- };
-
- struct tm AsStructTmLocal() const;
-
- struct tm AsStructTmUTC() const;
-
- operator struct tm() const {
- return AsStructTmLocal();
- }
-
+ }
+
+ bool IsUTC() const {
+ return !IsDst && !GMTOff;
+ }
+
+ time_t AsTimeT() const;
+
+ operator time_t() const {
+ return AsTimeT();
+ };
+
+ struct tm AsStructTmLocal() const;
+
+ struct tm AsStructTmUTC() const;
+
+ operator struct tm() const {
+ return AsStructTmLocal();
+ }
+
ui32 RealYear() const {
return ui32(Year + 1900);
}
-
+
ui32 RealMonth() const {
return ui32(Mon + 1);
}
-
- TSimpleTM& SetRealDate(ui32 year, ui32 mon, ui32 mday, ui32 hour = -1, ui32 min = -1, ui32 sec = -1, i32 isdst = 0);
-
- // regenerates all fields from Year, MDay, Hour, Min, Sec, IsDst, GMTOffset
- TSimpleTM& RegenerateFields();
-
+
+ TSimpleTM& SetRealDate(ui32 year, ui32 mon, ui32 mday, ui32 hour = -1, ui32 min = -1, ui32 sec = -1, i32 isdst = 0);
+
+ // regenerates all fields from Year, MDay, Hour, Min, Sec, IsDst, GMTOffset
+ TSimpleTM& RegenerateFields();
+
friend bool operator==(const TSimpleTM& a, const TSimpleTM& b) {
- return a.AsTimeT() == b.AsTimeT();
+ return a.AsTimeT() == b.AsTimeT();
}
-
+
friend bool operator==(const TSimpleTM& s, const struct tm& t) {
return s == New(t);
}
-
+
friend bool operator==(const struct tm& t, const TSimpleTM& s) {
return s == t;
}
-
+
friend bool operator!=(const TSimpleTM& a, const TSimpleTM& b) {
return !(a == b);
}
-
+
friend bool operator!=(const TSimpleTM& s, const struct tm& t) {
return !(s == t);
}
-
+
friend bool operator!=(const struct tm& t, const TSimpleTM& s) {
return s != t;
}
};
-}
+}
inline TString date2str(const time_t date) {
- struct tm dateTm;
- memset(&dateTm, 0, sizeof(dateTm));
- localtime_r(&date, &dateTm);
+ struct tm dateTm;
+ memset(&dateTm, 0, sizeof(dateTm));
+ localtime_r(&date, &dateTm);
char buf[9];
strftime(buf, sizeof(buf), "%Y%m%d", &dateTm);
return TString(buf);
}
inline time_t str2date(const TString& dateStr) {
- struct tm dateTm;
+ struct tm dateTm;
memset(&dateTm, 0, sizeof(tm));
strptime(dateStr.data(), "%Y%m%d", &dateTm);
return mktime(&dateTm);
diff --git a/util/draft/datetime_ut.cpp b/util/draft/datetime_ut.cpp
index f959848d5e..a5e065ef6e 100644
--- a/util/draft/datetime_ut.cpp
+++ b/util/draft/datetime_ut.cpp
@@ -1,66 +1,66 @@
#include "datetime.h"
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/string/builder.h>
Y_UNIT_TEST_SUITE(TSimpleTMTest) {
TString PrintMarker(const TString& test, int line) {
return TStringBuilder() << "test " << test << " at line " << line;
- }
-
+ }
+
TString JoinMarker(const TString& marker, time_t t) {
return TStringBuilder() << marker << " (tstamp=" << t << ")";
- }
-
+ }
+
TString PrintMarker(const TString& test, int line, time_t t) {
- return JoinMarker(PrintMarker(test, line), t);
- }
-
+ return JoinMarker(PrintMarker(test, line), t);
+ }
+
void AssertStructTmEqual(const TString& marker, const struct tm& tmt, const NDatetime::TSimpleTM& tms) {
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, tmt.tm_sec, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Min, tmt.tm_min, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Hour, tmt.tm_hour, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.WDay, tmt.tm_wday, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.MDay, tmt.tm_mday, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Mon, tmt.tm_mon, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.YDay, tmt.tm_yday, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Year, tmt.tm_year, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.IsDst, tmt.tm_isdst, marker);
-#ifndef _win_
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.GMTOff, tmt.tm_gmtoff, marker);
-#endif
- }
-
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, tmt.tm_sec, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Min, tmt.tm_min, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Hour, tmt.tm_hour, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.WDay, tmt.tm_wday, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.MDay, tmt.tm_mday, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Mon, tmt.tm_mon, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.YDay, tmt.tm_yday, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Year, tmt.tm_year, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.IsDst, tmt.tm_isdst, marker);
+#ifndef _win_
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.GMTOff, tmt.tm_gmtoff, marker);
+#endif
+ }
+
void AssertSimpleTM(const TString& mark,
- const NDatetime::TSimpleTM& tms,
- time_t tstamp, ui32 year, ui32 mon, ui32 mday, ui32 hour, ui32 minu, ui32 sec) {
+ const NDatetime::TSimpleTM& tms,
+ time_t tstamp, ui32 year, ui32 mon, ui32 mday, ui32 hour, ui32 minu, ui32 sec) {
TString marker = JoinMarker(mark, tstamp);
- struct tm tmt;
- Zero(tmt);
- GmTimeR(&tstamp, &tmt);
- AssertStructTmEqual(marker, tmt, tms);
- tmt = tms.AsStructTmUTC();
- time_t tstamp1 = TimeGM(&tmt);
- UNIT_ASSERT_VALUES_EQUAL_C(tstamp, tstamp1, marker);
- UNIT_ASSERT_VALUES_EQUAL_C(tstamp, tms.AsTimeT(), marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.RealYear(), year, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.RealMonth(), mon, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.MDay, mday, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Hour, hour, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Min, minu, marker);
- UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, sec, marker);
- }
-
+ struct tm tmt;
+ Zero(tmt);
+ GmTimeR(&tstamp, &tmt);
+ AssertStructTmEqual(marker, tmt, tms);
+ tmt = tms.AsStructTmUTC();
+ time_t tstamp1 = TimeGM(&tmt);
+ UNIT_ASSERT_VALUES_EQUAL_C(tstamp, tstamp1, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C(tstamp, tms.AsTimeT(), marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.RealYear(), year, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.RealMonth(), mon, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.MDay, mday, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Hour, hour, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Min, minu, marker);
+ UNIT_ASSERT_VALUES_EQUAL_C((int)tms.Sec, sec, marker);
+ }
+
Y_UNIT_TEST(TestLeap) {
- using namespace NDatetime;
+ using namespace NDatetime;
UNIT_ASSERT(LeapYearAD(2000));
UNIT_ASSERT(LeapYearAD(2012));
UNIT_ASSERT(!LeapYearAD(1999));
UNIT_ASSERT(LeapYearAD(2004));
UNIT_ASSERT(!LeapYearAD(1900));
- }
-
+ }
+
Y_UNIT_TEST(TestYDayConversion) {
using namespace NDatetime;
ui32 month;
@@ -81,151 +81,151 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
Y_UNIT_TEST(SimpleTMTest) {
using namespace NDatetime;
-
- tzset();
-
- TSimpleTM::New(-1); //should not die here
-
- UNIT_ASSERT_VALUES_EQUAL((ui32)0, (ui32)TSimpleTM::New(0));
- UNIT_ASSERT((ui32)TSimpleTM::New(0).IsUTC());
+
+ tzset();
+
+ TSimpleTM::New(-1); //should not die here
+
+ UNIT_ASSERT_VALUES_EQUAL((ui32)0, (ui32)TSimpleTM::New(0));
+ UNIT_ASSERT((ui32)TSimpleTM::New(0).IsUTC());
time_t t = time(nullptr);
-
+
{
- struct tm tmt;
- Zero(tmt);
- gmtime_r(&t, &tmt);
+ struct tm tmt;
+ Zero(tmt);
+ gmtime_r(&t, &tmt);
UNIT_ASSERT_VALUES_EQUAL_C((i64)t, (i64)TSimpleTM::New(t).AsTimeT(), ToString(t)); // time_t -> gmt tm -> time_t
- UNIT_ASSERT_VALUES_EQUAL_C((i64)t, (i64)TSimpleTM::New(tmt).AsTimeT(), ToString(t)); // gmt tm -> time_t
- AssertStructTmEqual(PrintMarker("UTC:time_t", __LINE__, t),
- tmt, TSimpleTM::New(t));
- AssertStructTmEqual(PrintMarker("UTC:tm", __LINE__, t),
- tmt, TSimpleTM::New(tmt));
- UNIT_ASSERT(TSimpleTM::New(t).IsUTC());
- UNIT_ASSERT(TSimpleTM::New(tmt).IsUTC());
+ UNIT_ASSERT_VALUES_EQUAL_C((i64)t, (i64)TSimpleTM::New(tmt).AsTimeT(), ToString(t)); // gmt tm -> time_t
+ AssertStructTmEqual(PrintMarker("UTC:time_t", __LINE__, t),
+ tmt, TSimpleTM::New(t));
+ AssertStructTmEqual(PrintMarker("UTC:tm", __LINE__, t),
+ tmt, TSimpleTM::New(tmt));
+ UNIT_ASSERT(TSimpleTM::New(t).IsUTC());
+ UNIT_ASSERT(TSimpleTM::New(tmt).IsUTC());
}
-
- {
- struct tm tmt;
- Zero(tmt);
- localtime_r(&t, &tmt);
-
- UNIT_ASSERT_VALUES_EQUAL((i64)t, (i64)TSimpleTM::NewLocal(t).AsTimeT()); // time_t -> local tm -> time_t
- UNIT_ASSERT_VALUES_EQUAL((i64)t, (i64)TSimpleTM::New(tmt).AsTimeT());
- AssertStructTmEqual(PrintMarker("local:time_t", __LINE__, t),
- tmt, TSimpleTM::NewLocal(t));
- AssertStructTmEqual(PrintMarker("local:tm", __LINE__, t),
- tmt, TSimpleTM::New(tmt));
- AssertStructTmEqual(PrintMarker("local:tm:RegenerateFields", __LINE__, t),
- tmt, TSimpleTM::New(tmt).RegenerateFields());
- AssertStructTmEqual(PrintMarker("local:time_t:SetRealDate", __LINE__, t),
+
+ {
+ struct tm tmt;
+ Zero(tmt);
+ localtime_r(&t, &tmt);
+
+ UNIT_ASSERT_VALUES_EQUAL((i64)t, (i64)TSimpleTM::NewLocal(t).AsTimeT()); // time_t -> local tm -> time_t
+ UNIT_ASSERT_VALUES_EQUAL((i64)t, (i64)TSimpleTM::New(tmt).AsTimeT());
+ AssertStructTmEqual(PrintMarker("local:time_t", __LINE__, t),
+ tmt, TSimpleTM::NewLocal(t));
+ AssertStructTmEqual(PrintMarker("local:tm", __LINE__, t),
+ tmt, TSimpleTM::New(tmt));
+ AssertStructTmEqual(PrintMarker("local:tm:RegenerateFields", __LINE__, t),
+ tmt, TSimpleTM::New(tmt).RegenerateFields());
+ AssertStructTmEqual(PrintMarker("local:time_t:SetRealDate", __LINE__, t),
tmt, TSimpleTM::NewLocal(t).SetRealDate(tmt.tm_year + 1900, tmt.tm_mon + 1, tmt.tm_mday, tmt.tm_hour, tmt.tm_min, tmt.tm_sec, tmt.tm_isdst));
- }
-
- {
- TSimpleTM tt = TSimpleTM::New(0);
-
- tt.SetRealDate(2012, 3, 30, 5, 6, 7);
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1333083967, 2012, 3, 30, 5, 6, 7);
-
- tt.SetRealDate(2012, 3, 8, 5, 6, 7);
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1331183167, 2012, 3, 8, 5, 6, 7);
-
- tt.SetRealDate(2010, 10, 4, 5, 6, 7);
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1286168767, 2010, 10, 4, 5, 6, 7);
-
- tt.Add(TSimpleTM::F_MON);
- AssertSimpleTM(PrintMarker("UTC:AddMonth", __LINE__),
- tt, 1288847167, 2010, 11, 4, 5, 6, 7);
-
- tt.Add(TSimpleTM::F_DAY);
- AssertSimpleTM(PrintMarker("UTC:AddDay", __LINE__),
- tt, 1288933567, 2010, 11, 5, 5, 6, 7);
-
- tt.Add(TSimpleTM::F_YEAR);
- AssertSimpleTM(PrintMarker("UTC:AddYear", __LINE__),
- tt, 1320469567, 2011, 11, 5, 5, 6, 7);
-
+ }
+
+ {
+ TSimpleTM tt = TSimpleTM::New(0);
+
+ tt.SetRealDate(2012, 3, 30, 5, 6, 7);
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1333083967, 2012, 3, 30, 5, 6, 7);
+
+ tt.SetRealDate(2012, 3, 8, 5, 6, 7);
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1331183167, 2012, 3, 8, 5, 6, 7);
+
+ tt.SetRealDate(2010, 10, 4, 5, 6, 7);
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1286168767, 2010, 10, 4, 5, 6, 7);
+
+ tt.Add(TSimpleTM::F_MON);
+ AssertSimpleTM(PrintMarker("UTC:AddMonth", __LINE__),
+ tt, 1288847167, 2010, 11, 4, 5, 6, 7);
+
+ tt.Add(TSimpleTM::F_DAY);
+ AssertSimpleTM(PrintMarker("UTC:AddDay", __LINE__),
+ tt, 1288933567, 2010, 11, 5, 5, 6, 7);
+
+ tt.Add(TSimpleTM::F_YEAR);
+ AssertSimpleTM(PrintMarker("UTC:AddYear", __LINE__),
+ tt, 1320469567, 2011, 11, 5, 5, 6, 7);
+
for (ui32 i = 0; i < 365; ++i) {
- tt.Add(TSimpleTM::F_DAY);
+ tt.Add(TSimpleTM::F_DAY);
}
-
- AssertSimpleTM(PrintMarker("UTC:365*AddDay", __LINE__),
- tt, 1352005567, 2012, 11, 4, 5, 6, 7);
-
- tt.Add(TSimpleTM::F_MON, -10);
- AssertSimpleTM(PrintMarker("UTC:AddMonth(-10)", __LINE__),
- tt, 1325653567, 2012, 1, 4, 5, 6, 7);
-
- tt.Add(TSimpleTM::F_HOUR, -24 * 4 - 6);
- AssertSimpleTM(PrintMarker("UTC:AddHour(-102)", __LINE__),
- tt, 1325286367, 2011, 12, 30, 23, 6, 7);
- }
-
- {
- TSimpleTM tt = TSimpleTM::New();
-
- tt.SetRealDate(2012, 2, 29);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1330473600, 2012, 2, 29, 0, 0, 0);
-
- tt.SetRealDate(2012, 2, 29);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1330473600, 2012, 2, 29, 0, 0, 0);
-
- tt.SetRealDate(2013, 12, 28);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1388188800, 2013, 12, 28, 0, 0, 0);
-
- tt.SetRealDate(2012, 10, 23);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1350950400, 2012, 10, 23, 0, 0, 0);
-
- tt.SetRealDate(2013, 3, 16);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1363392000, 2013, 3, 16, 0, 0, 0);
-
- tt.SetRealDate(2013, 2, 17);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1361059200, 2013, 2, 17, 0, 0, 0);
-
- tt.SetRealDate(2012, 12, 23);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1356220800, 2012, 12, 23, 0, 0, 0);
-
- tt.SetRealDate(2012, 5, 17);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1337212800, 2012, 5, 17, 0, 0, 0);
-
- tt.SetRealDate(2012, 6, 15);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1339718400, 2012, 6, 15, 0, 0, 0);
-
- tt.SetRealDate(2009, 3, 17);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1237248000, 2009, 3, 17, 0, 0, 0);
-
- tt.SetRealDate(2013, 8, 12);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1376265600, 2013, 8, 12, 0, 0, 0);
-
- tt.SetRealDate(2015, 12, 11, 10, 9, 8);
-
- AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
- tt, 1449828548, 2015, 12, 11, 10, 9, 8);
- }
- }
-}
+
+ AssertSimpleTM(PrintMarker("UTC:365*AddDay", __LINE__),
+ tt, 1352005567, 2012, 11, 4, 5, 6, 7);
+
+ tt.Add(TSimpleTM::F_MON, -10);
+ AssertSimpleTM(PrintMarker("UTC:AddMonth(-10)", __LINE__),
+ tt, 1325653567, 2012, 1, 4, 5, 6, 7);
+
+ tt.Add(TSimpleTM::F_HOUR, -24 * 4 - 6);
+ AssertSimpleTM(PrintMarker("UTC:AddHour(-102)", __LINE__),
+ tt, 1325286367, 2011, 12, 30, 23, 6, 7);
+ }
+
+ {
+ TSimpleTM tt = TSimpleTM::New();
+
+ tt.SetRealDate(2012, 2, 29);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1330473600, 2012, 2, 29, 0, 0, 0);
+
+ tt.SetRealDate(2012, 2, 29);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1330473600, 2012, 2, 29, 0, 0, 0);
+
+ tt.SetRealDate(2013, 12, 28);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1388188800, 2013, 12, 28, 0, 0, 0);
+
+ tt.SetRealDate(2012, 10, 23);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1350950400, 2012, 10, 23, 0, 0, 0);
+
+ tt.SetRealDate(2013, 3, 16);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1363392000, 2013, 3, 16, 0, 0, 0);
+
+ tt.SetRealDate(2013, 2, 17);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1361059200, 2013, 2, 17, 0, 0, 0);
+
+ tt.SetRealDate(2012, 12, 23);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1356220800, 2012, 12, 23, 0, 0, 0);
+
+ tt.SetRealDate(2012, 5, 17);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1337212800, 2012, 5, 17, 0, 0, 0);
+
+ tt.SetRealDate(2012, 6, 15);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1339718400, 2012, 6, 15, 0, 0, 0);
+
+ tt.SetRealDate(2009, 3, 17);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1237248000, 2009, 3, 17, 0, 0, 0);
+
+ tt.SetRealDate(2013, 8, 12);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1376265600, 2013, 8, 12, 0, 0, 0);
+
+ tt.SetRealDate(2015, 12, 11, 10, 9, 8);
+
+ AssertSimpleTM(PrintMarker("UTC:SetRealDate", __LINE__),
+ tt, 1449828548, 2015, 12, 11, 10, 9, 8);
+ }
+ }
+}
diff --git a/util/draft/enum.h b/util/draft/enum.h
index f1a80d4640..18002b7df2 100644
--- a/util/draft/enum.h
+++ b/util/draft/enum.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <bitset>
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index 9b8c0db7eb..1c62055bd9 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/ptr.h>
#include <util/generic/vector.h>
diff --git a/util/draft/matrix.h b/util/draft/matrix.h
index 8ffc439393..154d00b35e 100644
--- a/util/draft/matrix.h
+++ b/util/draft/matrix.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/noncopyable.h>
#include <util/system/yassert.h>
diff --git a/util/draft/ya.make b/util/draft/ya.make
index 3201221981..e00674b682 100644
--- a/util/draft/ya.make
+++ b/util/draft/ya.make
@@ -11,7 +11,7 @@ ENDIF()
SRCS(
date.cpp
- datetime.cpp
+ datetime.cpp
enum.cpp
holder_vector.cpp
ip.cpp
diff --git a/util/folder/dirent_win.h b/util/folder/dirent_win.h
index 449200333c..ac11a64c04 100644
--- a/util/folder/dirent_win.h
+++ b/util/folder/dirent_win.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index fa2c27bed6..ffc9b09f96 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -436,7 +436,7 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
sysTmp = GetSystemTempDir();
prefix = sysTmp.data();
}
-
+
if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0)
return ret;
if (!TFileStat(path).IsDir())
diff --git a/util/folder/dirut.h b/util/folder/dirut.h
index 2f9f670d5a..2537027b12 100644
--- a/util/folder/dirut.h
+++ b/util/folder/dirut.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
#include <util/system/sysstat.h>
@@ -72,7 +72,7 @@ TString RealPath(const TString& path); // throws
TString RealLocation(const TString& path); /// throws; last file name component doesn't need to exist
TString GetSystemTempDir();
-
+
int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix);
int ResolvePath(const char* rel, const char* abs, char res[/*FILENAME_MAX*/], bool isdir = false);
diff --git a/util/folder/filelist.h b/util/folder/filelist.h
index 48cd9aceb9..3f615fa4c2 100644
--- a/util/folder/filelist.h
+++ b/util/folder/filelist.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/buffer.h>
#include <util/generic/string.h>
diff --git a/util/folder/iterator.h b/util/folder/iterator.h
index 536b111dc1..69e025b9c4 100644
--- a/util/folder/iterator.h
+++ b/util/folder/iterator.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fts.h"
diff --git a/util/folder/lstat_win.h b/util/folder/lstat_win.h
index 7df2a6a74d..0bf7c19055 100644
--- a/util/folder/lstat_win.h
+++ b/util/folder/lstat_win.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
#include "fts.h"
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index a29c9855fa..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -68,7 +68,7 @@ TFsPath TFsPath::RelativeTo(const TFsPath& root) const {
}
if (!this->IsSubpathOf(root)) {
- ythrow TIoException() << "path " << *this << " is not subpath of " << root;
+ ythrow TIoException() << "path " << *this << " is not subpath of " << root;
}
split.erase(split.begin(), split.begin() + rsplit.size());
@@ -121,9 +121,9 @@ TFsPath& TFsPath::operator/=(const TFsPath& that) {
} else if (that.IsDefined() && that.GetPath() != ".") {
if (!that.IsRelative()) {
- ythrow TIoException() << "path should be relative: " << that.GetPath();
+ ythrow TIoException() << "path should be relative: " << that.GetPath();
}
-
+
TSplit split = GetSplit();
const TSplit& rsplit = that.GetSplit();
split.insert(split.end(), rsplit.begin(), rsplit.end());
@@ -212,7 +212,7 @@ TFsPath::TFsPath(const char* path)
TFsPath TFsPath::Child(const TString& name) const {
if (!name) {
- ythrow TIoException() << "child name must not be empty";
+ ythrow TIoException() << "child name must not be empty";
}
return *this / name;
@@ -222,7 +222,7 @@ struct TClosedir {
static void Destroy(DIR* dir) {
if (dir) {
if (0 != closedir(dir)) {
- ythrow TIoSystemError() << "failed to closedir";
+ ythrow TIoSystemError() << "failed to closedir";
}
}
}
@@ -232,7 +232,7 @@ void TFsPath::ListNames(TVector<TString>& children) const {
CheckDefined();
THolder<DIR, TClosedir> dir(opendir(this->c_str()));
if (!dir) {
- ythrow TIoSystemError() << "failed to opendir " << Path_;
+ ythrow TIoSystemError() << "failed to opendir " << Path_;
}
for (;;) {
@@ -245,7 +245,7 @@ void TFsPath::ListNames(TVector<TString>& children) const {
int r = readdir_r(dir.Get(), &de, &ok);
Y_PRAGMA_DIAGNOSTIC_POP
if (r != 0) {
- ythrow TIoSystemError() << "failed to readdir " << Path_;
+ ythrow TIoSystemError() << "failed to readdir " << Path_;
}
if (ok == nullptr) {
return;
@@ -319,16 +319,16 @@ TFsPath TFsPath::RealLocation() const {
return ::RealLocation(*this);
}
-TFsPath TFsPath::ReadLink() const {
- CheckDefined();
-
+TFsPath TFsPath::ReadLink() const {
+ CheckDefined();
+
if (!IsSymlink()) {
- ythrow TIoException() << "not a symlink " << *this;
+ ythrow TIoException() << "not a symlink " << *this;
}
-
+
return NFs::ReadLink(*this);
-}
-
+}
+
bool TFsPath::Exists() const {
return IsDefined() && NFs::Exists(*this);
}
@@ -343,14 +343,14 @@ bool TFsPath::IsDirectory() const {
return IsDefined() && TFileStat(GetPath().data()).IsDir();
}
-bool TFsPath::IsFile() const {
+bool TFsPath::IsFile() const {
return IsDefined() && TFileStat(GetPath().data()).IsFile();
-}
-
-bool TFsPath::IsSymlink() const {
+}
+
+bool TFsPath::IsSymlink() const {
return IsDefined() && TFileStat(GetPath().data(), true).IsSymlink();
-}
-
+}
+
void TFsPath::DeleteIfExists() const {
if (!IsDefined()) {
return;
diff --git a/util/folder/path.h b/util/folder/path.h
index 1be66799da..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "pathsplit.h"
@@ -174,9 +174,9 @@ public:
bool Exists() const;
/// false if not exists
bool IsDirectory() const;
- /// false if not exists
- bool IsFile() const;
- /// false if not exists
+ /// false if not exists
+ bool IsFile() const;
+ /// false if not exists
bool IsSymlink() const;
/// throw TIoException if not exists
void CheckExists() const;
@@ -192,7 +192,7 @@ public:
TFsPath RealPath() const;
TFsPath RealLocation() const;
- TFsPath ReadLink() const;
+ TFsPath ReadLink() const;
/// always absolute
static TFsPath Cwd();
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index 3d73275c31..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "is_in.h"
#include "utility.h"
@@ -308,11 +308,11 @@ static inline T Unique(T f, T l, P p) {
return std::unique(f, l, p);
}
-template <class T, class TGetKey>
-static inline T UniqueBy(T f, T l, const TGetKey& getKey) {
- return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); });
-}
-
+template <class T, class TGetKey>
+static inline T UniqueBy(T f, T l, const TGetKey& getKey) {
+ return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); });
+}
+
template <class C>
void SortUnique(C& c) {
Sort(c.begin(), c.end());
@@ -325,18 +325,18 @@ void SortUnique(C& c, Cmp cmp) {
c.erase(Unique(c.begin(), c.end()), c.end());
}
-template <class C, class TGetKey>
-void SortUniqueBy(C& c, const TGetKey& getKey) {
- SortBy(c, getKey);
+template <class C, class TGetKey>
+void SortUniqueBy(C& c, const TGetKey& getKey) {
+ SortBy(c, getKey);
c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end());
-}
-
-template <class C, class TGetKey>
-void StableSortUniqueBy(C& c, const TGetKey& getKey) {
- StableSortBy(c, getKey);
+}
+
+template <class C, class TGetKey>
+void StableSortUniqueBy(C& c, const TGetKey& getKey) {
+ StableSortBy(c, getKey);
c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end());
-}
-
+}
+
template <class C, class TValue>
void Erase(C& c, const TValue& value) {
c.erase(std::remove(c.begin(), c.end(), value), c.end());
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index a26e70a3d6..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -517,18 +517,18 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(SortUniqueByTest) {
TVector<int> collection = {404, 101, 101, 203, 101, 203, 404};
- StableSortUniqueBy(collection, [](int x) { return x / 100; });
+ StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
- UNIT_ASSERT_VALUES_EQUAL(collection, expected);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(collection, expected);
+ }
+
Y_UNIT_TEST(StableSortUniqueByTest) {
TVector<int> collection = {404, 101, 106, 203, 102, 205, 401};
- StableSortUniqueBy(collection, [](int x) { return x / 100; });
+ StableSortUniqueBy(collection, [](int x) { return x / 100; });
TVector<int> expected = {101, 203, 404};
- UNIT_ASSERT_VALUES_EQUAL(collection, expected);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(collection, expected);
+ }
+
Y_UNIT_TEST(IotaTest) {
TVector<int> v(10);
diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h
index da5dcbc74d..f77d182460 100644
--- a/util/generic/bitmap.h
+++ b/util/generic/bitmap.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "ptr.h"
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index cbe342f170..2db15fc59b 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "ylimits.h"
#include "typelist.h"
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index 7e6c3d3a99..9576467404 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "utility.h"
@@ -8,7 +8,7 @@
#include <cstring>
-class TBuffer {
+class TBuffer {
public:
using TIterator = char*;
using TConstIterator = const char*;
@@ -23,7 +23,7 @@ public:
{
*this = b;
}
-
+
TBuffer(TBuffer&& b) noexcept;
TBuffer& operator=(TBuffer&& b) noexcept;
@@ -34,7 +34,7 @@ public:
}
return *this;
}
-
+
~TBuffer();
inline void Clear() noexcept {
diff --git a/util/generic/cast.h b/util/generic/cast.h
index 0ca257a7a2..0d4a41f385 100644
--- a/util/generic/cast.h
+++ b/util/generic/cast.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "typetraits.h"
#include "yexception.h"
diff --git a/util/generic/deque.h b/util/generic/deque.h
index 2079c70ba5..2dabaf3177 100644
--- a/util/generic/deque.h
+++ b/util/generic/deque.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
diff --git a/util/generic/hash.h b/util/generic/hash.h
index 69ba84dec6..e46db21fa9 100644
--- a/util/generic/hash.h
+++ b/util/generic/hash.h
@@ -701,7 +701,7 @@ public:
*ins = tmp;
++num_elements;
return iterator(tmp);
- }
+ }
template <typename... Args>
std::pair<iterator, bool> emplace_unique(Args&&... args) {
@@ -1616,7 +1616,7 @@ public:
const_iterator find(const TheKey& key) const {
return rep.find(key);
}
-
+
template <class TheKey>
iterator find(const TheKey& key, insert_ctx& ins) {
return rep.find_i(key, ins);
diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h
index becab74c4f..b5d3f2051b 100644
--- a/util/generic/intrlist.h
+++ b/util/generic/intrlist.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "utility.h"
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index 1a9a856132..19e9d20976 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <iterator>
#include <utility>
diff --git a/util/generic/list.h b/util/generic/list.h
index df16951531..7b0b8ffc72 100644
--- a/util/generic/list.h
+++ b/util/generic/list.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
diff --git a/util/generic/map.h b/util/generic/map.h
index 3a8f4bc2a9..b5001b56c0 100644
--- a/util/generic/map.h
+++ b/util/generic/map.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "mapfindptr.h"
diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp
index e6bce5ebab..79e832b024 100644
--- a/util/generic/map_ut.cpp
+++ b/util/generic/map_ut.cpp
@@ -1,40 +1,40 @@
#include "map.h"
#include <library/cpp/testing/unittest/registar.h>
-#include <util/memory/pool.h>
+#include <util/memory/pool.h>
#include <algorithm>
Y_UNIT_TEST_SUITE(TYMapTest) {
template <typename TAlloc>
void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m);
-
+
template <typename TAlloc>
void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm);
-
+
Y_UNIT_TEST(TestMap1) {
{
TMap<char, int, TLess<char>> m;
DoTestMap1(m);
- }
+ }
{
TMemoryPool p(100);
TMap<char, int, TLess<char>, TPoolAllocator> m(&p);
DoTestMap1(m);
}
}
-
+
Y_UNIT_TEST(TestMMap1) {
{
TMultiMap<char, int, TLess<char>> mm;
DoTestMMap1(mm);
- }
+ }
{
TMemoryPool p(100);
TMultiMap<char, int, TLess<char>, TPoolAllocator> mm(&p);
DoTestMMap1(mm);
}
}
-
+
template <typename TAlloc>
void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m) {
using maptype = TMap<char, int, TLess<char>, TAlloc>;
@@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) {
template <typename TAlloc>
void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& m) {
using mmap = TMultiMap<char, int, TLess<char>, TAlloc>;
-
+
UNIT_ASSERT(m.count('X') == 0);
m.insert(std::pair<const char, int>('X', 10)); // Standard way.
diff --git a/util/generic/maybe.h b/util/generic/maybe.h
index a897490ca6..34d21aebcd 100644
--- a/util/generic/maybe.h
+++ b/util/generic/maybe.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <utility>
diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp
index f11bdcb730..2c1a425c5e 100644
--- a/util/generic/maybe_ut.cpp
+++ b/util/generic/maybe_ut.cpp
@@ -225,20 +225,20 @@ Y_UNIT_TEST_SUITE(TMaybeTest) {
Y_UNIT_TEST(TestGetOr) {
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx"));
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy"));
-
- {
+
+ {
TString xxx = "xxx";
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse(xxx).append('x'), TString("xxxx"));
- UNIT_ASSERT_VALUES_EQUAL(xxx, "xxxx");
- }
-
- {
+ UNIT_ASSERT_VALUES_EQUAL(xxx, "xxxx");
+ }
+
+ {
TString xxx = "xxx";
UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse(xxx).append('x'), TString("yyyx"));
- UNIT_ASSERT_VALUES_EQUAL(xxx, "xxx");
- }
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(xxx, "xxx");
+ }
+ }
+
/*
==
!=
diff --git a/util/generic/noncopyable.h b/util/generic/noncopyable.h
index a50961b7b6..c007934133 100644
--- a/util/generic/noncopyable.h
+++ b/util/generic/noncopyable.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
/**
* @class TNonCopyable
@@ -21,18 +21,18 @@ namespace NNonCopyable { // protection from unintended ADL
TNonCopyable() = default;
~TNonCopyable() = default;
};
-
+
struct TMoveOnly {
TMoveOnly(TMoveOnly&&) noexcept = default;
TMoveOnly& operator=(TMoveOnly&&) noexcept = default;
-
- TMoveOnly(const TMoveOnly&) = delete;
- TMoveOnly& operator=(const TMoveOnly&) = delete;
-
- TMoveOnly() = default;
- ~TMoveOnly() = default;
- };
+
+ TMoveOnly(const TMoveOnly&) = delete;
+ TMoveOnly& operator=(const TMoveOnly&) = delete;
+
+ TMoveOnly() = default;
+ ~TMoveOnly() = default;
+ };
}
using TNonCopyable = NNonCopyable::TNonCopyable;
-using TMoveOnly = NNonCopyable::TMoveOnly;
+using TMoveOnly = NNonCopyable::TMoveOnly;
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 043d264316..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "utility.h"
@@ -41,13 +41,13 @@ inline void CheckedArrayDelete(T* t) {
delete[] t;
}
-class TNoAction {
+class TNoAction {
public:
template <class T>
static inline void Destroy(T*) noexcept {
}
-};
-
+};
+
class TDelete {
public:
template <class T>
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index 10460ad632..966e853b77 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/guard.h>
#include <util/system/atomic.h>
diff --git a/util/generic/set.h b/util/generic/set.h
index 373f42f984..4c437ca26f 100644
--- a/util/generic/set.h
+++ b/util/generic/set.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
diff --git a/util/generic/singleton.h b/util/generic/singleton.h
index bedfa7adbe..f5fa047f5c 100644
--- a/util/generic/singleton.h
+++ b/util/generic/singleton.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/atexit.h>
#include <util/system/atomic.h>
diff --git a/util/generic/stack.h b/util/generic/stack.h
index c07c58faa2..dbcbf2b5c9 100644
--- a/util/generic/stack.h
+++ b/util/generic/stack.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "deque.h"
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 050a32bfb4..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// Some of these includes are just a legacy from previous implementation.
// We don't need them here, but removing them is tricky because it breaks all
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 18576be409..70b9360d58 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "strbase.h"
@@ -345,14 +345,14 @@ public:
}
public:
- // returns tail, including pos
+ // returns tail, including pos
TdSelf SplitOffAt(size_t pos) {
const TdSelf tok = SubStr(pos);
Trunc(pos);
return tok;
}
- // returns head, tail includes pos
+ // returns head, tail includes pos
TdSelf NextTokAt(size_t pos) {
const TdSelf tok = Head(pos);
Skip(pos);
diff --git a/util/generic/strfcpy.h b/util/generic/strfcpy.h
index b44f797185..8a95bc3df2 100644
--- a/util/generic/strfcpy.h
+++ b/util/generic/strfcpy.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
/*
* strfcpy is a faster version of strlcpy().
diff --git a/util/generic/string.h b/util/generic/string.h
index 9375f5a3d6..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <cstddef>
#include <cstring>
diff --git a/util/generic/typelist.h b/util/generic/typelist.h
index a964fa3071..5ce26ab97c 100644
--- a/util/generic/typelist.h
+++ b/util/generic/typelist.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/types.h>
diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h
index 2811cf81ab..d165bd1a06 100644
--- a/util/generic/typetraits.h
+++ b/util/generic/typetraits.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "va_args.h"
diff --git a/util/generic/utility.h b/util/generic/utility.h
index bb0534d297..43b98eeafc 100644
--- a/util/generic/utility.h
+++ b/util/generic/utility.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "typetraits.h"
diff --git a/util/generic/variant.h b/util/generic/variant.h
index 9c88969623..749fc75090 100644
--- a/util/generic/variant.h
+++ b/util/generic/variant.h
@@ -1,18 +1,18 @@
#pragma once
#include "hash.h"
-
+
#include <variant>
-
-template <class... Ts>
+
+template <class... Ts>
struct THash<std::variant<Ts...>> {
-public:
+public:
size_t operator()(const std::variant<Ts...>& v) const noexcept {
return CombineHashes(
IntHash(v.index()),
v.valueless_by_exception() ? 0 : std::visit([](const auto& value) { return ComputeHash(value); }, v));
- }
-};
+ }
+};
template <>
struct THash<std::monostate> {
diff --git a/util/generic/vector.h b/util/generic/vector.h
index d635ad773d..a5b258955a 100644
--- a/util/generic/vector.h
+++ b/util/generic/vector.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "reserve.h"
diff --git a/util/generic/yexception.h b/util/generic/yexception.h
index cde2c87c7b..b0c604e8c4 100644
--- a/util/generic/yexception.h
+++ b/util/generic/yexception.h
@@ -1,7 +1,7 @@
-#pragma once
+#pragma once
#include "bt_exception.h"
-#include "strbuf.h"
+#include "strbuf.h"
#include "string.h"
#include "utility.h"
#include "va_args.h"
diff --git a/util/generic/yexception_ut.h b/util/generic/yexception_ut.h
index ce5546cda4..acf6f27e99 100644
--- a/util/generic/yexception_ut.h
+++ b/util/generic/yexception_ut.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#ifdef __cplusplus
extern "C" {
diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h
index 5f02998c56..fe42b4dfc0 100644
--- a/util/generic/ylimits.h
+++ b/util/generic/ylimits.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <limits>
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 3a9078e6a6..9ff9ae2abe 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/yassert.h>
#include <util/system/defaults.h>
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 87fd0ad0fa..29190b55eb 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -1,4 +1,4 @@
-#include "bitops.h"
+#include "bitops.h"
#include "ymath.h"
#include <library/cpp/testing/unittest/registar.h>
diff --git a/util/memory/addstorage.h b/util/memory/addstorage.h
index 7ecbd0ebd5..597c73a988 100644
--- a/util/memory/addstorage.h
+++ b/util/memory/addstorage.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/align.h>
#include <util/system/defaults.h>
diff --git a/util/memory/alloc.h b/util/memory/alloc.h
index 9e45e3e547..d59575aef5 100644
--- a/util/memory/alloc.h
+++ b/util/memory/alloc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <memory>
diff --git a/util/memory/blob.h b/util/memory/blob.h
index b9bfcf5645..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
#include <util/generic/strbuf.h>
diff --git a/util/memory/mmapalloc.h b/util/memory/mmapalloc.h
index 5c984a3ebd..06002e58fc 100644
--- a/util/memory/mmapalloc.h
+++ b/util/memory/mmapalloc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
class IAllocator;
diff --git a/util/memory/pool.h b/util/memory/pool.h
index 48494cb33d..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "alloc.h"
@@ -7,7 +7,7 @@
#include <util/generic/bitops.h>
#include <util/generic/utility.h>
#include <util/generic/intrlist.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/singleton.h>
#include <new>
@@ -79,7 +79,7 @@ private:
inline char* Data() noexcept {
return (char*)(this + 1);
}
-
+
inline size_t DataSize() const noexcept {
return Cur_ - Data();
}
@@ -157,22 +157,22 @@ public:
template <typename T>
inline T* Allocate() {
- return (T*)this->Allocate(sizeof(T), alignof(T));
+ return (T*)this->Allocate(sizeof(T), alignof(T));
}
template <typename T>
inline T* Allocate(size_t align) {
- return (T*)this->Allocate(sizeof(T), Max(align, alignof(T)));
+ return (T*)this->Allocate(sizeof(T), Max(align, alignof(T)));
}
template <typename T>
inline T* AllocateArray(size_t count) {
- return (T*)this->Allocate(sizeof(T) * count, alignof(T));
+ return (T*)this->Allocate(sizeof(T) * count, alignof(T));
}
template <typename T>
inline T* AllocateArray(size_t count, size_t align) {
- return (T*)this->Allocate(sizeof(T) * count, Max(align, alignof(T)));
+ return (T*)this->Allocate(sizeof(T) * count, Max(align, alignof(T)));
}
template <typename T>
@@ -196,7 +196,7 @@ public:
template <typename T>
inline T* NewArray(size_t count) {
- T* arr = (T*)AllocateArray<T>(count);
+ T* arr = (T*)AllocateArray<T>(count);
for (T *ptr = arr, *end = arr + count; ptr != end; ++ptr) {
new (ptr) T;
@@ -217,12 +217,12 @@ public:
std::char_traits<TChar>::copy(ret, str, len);
return ret;
}
-
+
template <typename TChar>
inline TBasicStringBuf<TChar> AppendString(const TBasicStringBuf<TChar>& buf) {
return TBasicStringBuf<TChar>(Append(buf.data(), buf.size()), buf.size());
}
-
+
template <typename TChar>
inline TBasicStringBuf<TChar> AppendCString(const TBasicStringBuf<TChar>& buf) {
TChar* ret = static_cast<TChar*>(Allocate((buf.size() + 1) * sizeof(TChar)));
@@ -292,7 +292,7 @@ protected:
private:
void AddChunk(size_t hint);
void DoClear(bool keepfirst) noexcept;
-
+
private:
TChunk Empty_;
TChunk* Current_;
@@ -321,9 +321,9 @@ struct TPoolableBase {
inline void operator delete(void*, TPool&) noexcept {
}
-
-private:
- inline void* operator new(size_t); // disallow default allocation
+
+private:
+ inline void* operator new(size_t); // disallow default allocation
};
struct TPoolable: public TPoolableBase<TMemoryPool> {
@@ -371,7 +371,7 @@ public:
: Pool_(o.GetPool())
{
}
-
+
inline T* allocate(size_t n) {
return (T*)Pool_->Allocate(n * sizeof(T), alignof(T));
}
@@ -401,7 +401,7 @@ public:
inline TPool* GetPool() const {
return Pool_;
}
-
+
inline friend bool operator==(const TPoolAllocBase& l, const TPoolAllocBase& r) {
return l.Pool_ == r.Pool_;
}
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index dc5893778a..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -99,33 +99,33 @@ private:
}
alloc.CheckAtEnd();
-
+
{
TMemoryPool pool(150, TMemoryPool::TExpGrow::Instance(), &alloc);
-
+
pool.Allocate(8);
-
+
size_t memavail = pool.Available();
size_t memwaste = pool.MemoryWaste();
size_t memalloc = pool.MemoryAllocated();
-
+
for (size_t i = 0; i < 1000; ++i) {
void* m = pool.Allocate(i);
UNIT_ASSERT(m);
memset(m, 0, i);
}
-
+
pool.ClearKeepFirstChunk();
-
+
UNIT_ASSERT_VALUES_EQUAL(memalloc - 8, pool.MemoryAllocated());
UNIT_ASSERT_VALUES_EQUAL(memwaste + 8, pool.MemoryWaste());
UNIT_ASSERT_VALUES_EQUAL(memavail + 8, pool.Available());
-
+
for (size_t i = 0; i < 1000; ++i) {
void* m = pool.Allocate(i);
UNIT_ASSERT(m);
memset(m, 0, i);
- }
+ }
pool.Clear();
@@ -133,7 +133,7 @@ private:
UNIT_ASSERT_VALUES_EQUAL(0, pool.MemoryWaste());
UNIT_ASSERT_VALUES_EQUAL(0, pool.Available());
}
-
+
alloc.CheckAtEnd();
struct TConstructorTest {
diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h
index c8c724a2ae..a40aa408f5 100644
--- a/util/memory/segmented_string_pool.h
+++ b/util/memory/segmented_string_pool.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/align.h>
#include <util/system/yassert.h>
diff --git a/util/memory/segpool_alloc.h b/util/memory/segpool_alloc.h
index 2d6b5a0e3e..1a83b7a543 100644
--- a/util/memory/segpool_alloc.h
+++ b/util/memory/segpool_alloc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "segmented_string_pool.h"
diff --git a/util/memory/smallobj.h b/util/memory/smallobj.h
index 7501933758..63de666bae 100644
--- a/util/memory/smallobj.h
+++ b/util/memory/smallobj.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "pool.h"
#include "alloc.h"
@@ -16,14 +16,14 @@ class TFixedSizeAllocator {
return (TAlloc*)ptr;
}
- static constexpr size_t EntitySize(size_t alloc) noexcept {
+ static constexpr size_t EntitySize(size_t alloc) noexcept {
return Max(sizeof(TAlloc), alloc);
}
- static constexpr size_t EntityAlign(size_t align) noexcept {
- return Max(alignof(TAlloc), align);
- }
-
+ static constexpr size_t EntityAlign(size_t align) noexcept {
+ return Max(alignof(TAlloc), align);
+ }
+
static inline TAlloc* Construct(void* ptr) noexcept {
return (TAlloc*)ptr;
}
@@ -32,31 +32,31 @@ class TFixedSizeAllocator {
public:
using IGrowPolicy = TMemoryPool::IGrowPolicy;
- TFixedSizeAllocator(size_t allocSize, IAllocator* alloc)
- : TFixedSizeAllocator(allocSize, alignof(TAlloc), TMemoryPool::TExpGrow::Instance(), alloc)
+ TFixedSizeAllocator(size_t allocSize, IAllocator* alloc)
+ : TFixedSizeAllocator(allocSize, alignof(TAlloc), TMemoryPool::TExpGrow::Instance(), alloc)
+ {
+ }
+
+ TFixedSizeAllocator(size_t allocSize, size_t alignSize, IAllocator* alloc)
+ : TFixedSizeAllocator(allocSize, alignSize, TMemoryPool::TExpGrow::Instance(), alloc)
+ {
+ }
+
+ TFixedSizeAllocator(size_t allocSize, IGrowPolicy* grow, IAllocator* alloc)
+ : TFixedSizeAllocator(allocSize, alignof(TAlloc), grow, alloc)
{
}
- TFixedSizeAllocator(size_t allocSize, size_t alignSize, IAllocator* alloc)
- : TFixedSizeAllocator(allocSize, alignSize, TMemoryPool::TExpGrow::Instance(), alloc)
- {
- }
-
- TFixedSizeAllocator(size_t allocSize, IGrowPolicy* grow, IAllocator* alloc)
- : TFixedSizeAllocator(allocSize, alignof(TAlloc), grow, alloc)
- {
- }
-
- TFixedSizeAllocator(size_t allocSize, size_t alignSize, IGrowPolicy* grow, IAllocator* alloc)
+ TFixedSizeAllocator(size_t allocSize, size_t alignSize, IGrowPolicy* grow, IAllocator* alloc)
: Pool_(allocSize, grow, alloc)
- , AlignSize_(TAlloc::EntityAlign(alignSize))
- , AllocSize_(TAlloc::EntitySize(allocSize))
+ , AlignSize_(TAlloc::EntityAlign(alignSize))
+ , AllocSize_(TAlloc::EntitySize(allocSize))
{
}
inline void* Allocate() {
if (Y_UNLIKELY(Free_.Empty())) {
- return Pool_.Allocate(AllocSize_, AlignSize_);
+ return Pool_.Allocate(AllocSize_, AlignSize_);
}
return Free_.PopFront()->ToPointer();
@@ -72,7 +72,7 @@ public:
private:
TMemoryPool Pool_;
- const size_t AlignSize_;
+ const size_t AlignSize_;
const size_t AllocSize_;
TIntrusiveSList<TAlloc> Free_;
};
@@ -83,12 +83,12 @@ public:
using IGrowPolicy = TFixedSizeAllocator::IGrowPolicy;
inline TSmallObjAllocator(IAllocator* alloc)
- : Alloc_(sizeof(T), alignof(T), alloc)
+ : Alloc_(sizeof(T), alignof(T), alloc)
{
}
inline TSmallObjAllocator(IGrowPolicy* grow, IAllocator* alloc)
- : Alloc_(sizeof(T), alignof(T), grow, alloc)
+ : Alloc_(sizeof(T), alignof(T), grow, alloc)
{
}
diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp
index 6da02f0ecf..86003d1d53 100644
--- a/util/memory/smallobj_ut.cpp
+++ b/util/memory/smallobj_ut.cpp
@@ -18,29 +18,29 @@ class TSmallObjAllocTest: public TTestBase {
};
struct TClass64: public TObjectFromPool<TClass64> {
- alignas(64) ui64 Data = 0;
- };
-
+ alignas(64) ui64 Data = 0;
+ };
+
UNIT_TEST_SUITE(TSmallObjAllocTest);
- UNIT_TEST(TestAlign)
- UNIT_TEST(TestError)
+ UNIT_TEST(TestAlign)
+ UNIT_TEST(TestError)
UNIT_TEST(TestAllocate)
UNIT_TEST_SUITE_END();
private:
- void TestAlign() {
- TClass64::TPool pool(TDefaultAllocator::Instance());
+ void TestAlign() {
+ TClass64::TPool pool(TDefaultAllocator::Instance());
TClass64* f1 = new (&pool) TClass64;
TClass64* f2 = new (&pool) TClass64;
TClass64* f3 = new (&pool) TClass64;
TClass64* f4 = new (&pool) TClass64;
- UNIT_ASSERT_VALUES_EQUAL(64u, alignof(TClass64));
- UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f1) & (alignof(TClass64) - 1));
- UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f2) & (alignof(TClass64) - 1));
- UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f3) & (alignof(TClass64) - 1));
- UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f4) & (alignof(TClass64) - 1));
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(64u, alignof(TClass64));
+ UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f1) & (alignof(TClass64) - 1));
+ UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f2) & (alignof(TClass64) - 1));
+ UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f3) & (alignof(TClass64) - 1));
+ UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f4) & (alignof(TClass64) - 1));
+ }
+
inline void TestError() {
TErrClass::TPool pool(TDefaultAllocator::Instance());
TErrClass* f = new (&pool) TErrClass(false);
diff --git a/util/memory/tempbuf.h b/util/memory/tempbuf.h
index 38b967a718..334670eb1e 100644
--- a/util/memory/tempbuf.h
+++ b/util/memory/tempbuf.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
#include <util/generic/ptr.h>
diff --git a/util/network/address.cpp b/util/network/address.cpp
index 9040bb785e..a81a9e6994 100644
--- a/util/network/address.cpp
+++ b/util/network/address.cpp
@@ -94,26 +94,26 @@ void Out<IRemoteAddr>(IOutputStream& out, const IRemoteAddr& addr) {
PrintAddr<true>(out, addr);
}
-template <>
-void Out<NAddr::TAddrInfo>(IOutputStream& out, const NAddr::TAddrInfo& addr) {
- PrintAddr<true>(out, addr);
-}
-
-template <>
-void Out<NAddr::TIPv4Addr>(IOutputStream& out, const NAddr::TIPv4Addr& addr) {
- PrintAddr<true>(out, addr);
-}
-
-template <>
-void Out<NAddr::TIPv6Addr>(IOutputStream& out, const NAddr::TIPv6Addr& addr) {
- PrintAddr<true>(out, addr);
-}
-
-template <>
-void Out<NAddr::TOpaqueAddr>(IOutputStream& out, const NAddr::TOpaqueAddr& addr) {
- PrintAddr<true>(out, addr);
-}
-
+template <>
+void Out<NAddr::TAddrInfo>(IOutputStream& out, const NAddr::TAddrInfo& addr) {
+ PrintAddr<true>(out, addr);
+}
+
+template <>
+void Out<NAddr::TIPv4Addr>(IOutputStream& out, const NAddr::TIPv4Addr& addr) {
+ PrintAddr<true>(out, addr);
+}
+
+template <>
+void Out<NAddr::TIPv6Addr>(IOutputStream& out, const NAddr::TIPv6Addr& addr) {
+ PrintAddr<true>(out, addr);
+}
+
+template <>
+void Out<NAddr::TOpaqueAddr>(IOutputStream& out, const NAddr::TOpaqueAddr& addr) {
+ PrintAddr<true>(out, addr);
+}
+
void NAddr::PrintHost(IOutputStream& out, const IRemoteAddr& addr) {
PrintAddr<false>(out, addr);
}
diff --git a/util/network/hostip.h b/util/network/hostip.h
index b371ce25cd..cf63e4846a 100644
--- a/util/network/hostip.h
+++ b/util/network/hostip.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
diff --git a/util/network/init.h b/util/network/init.h
index ac29458621..08a79c0fca 100644
--- a/util/network/init.h
+++ b/util/network/init.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/error.h>
diff --git a/util/network/iovec.h b/util/network/iovec.h
index 07fb5a9373..ac15a41f54 100644
--- a/util/network/iovec.h
+++ b/util/network/iovec.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/stream/output.h>
#include <util/system/types.h>
diff --git a/util/network/ip.h b/util/network/ip.h
index 95ff346560..dc7c2d24a0 100644
--- a/util/network/ip.h
+++ b/util/network/ip.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "socket.h"
#include "hostip.h"
diff --git a/util/network/nonblock.h b/util/network/nonblock.h
index d7eb3dea2c..54e5e44ae3 100644
--- a/util/network/nonblock.h
+++ b/util/network/nonblock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "socket.h"
diff --git a/util/network/pair.h b/util/network/pair.h
index 747374b5db..0d4506f880 100644
--- a/util/network/pair.h
+++ b/util/network/pair.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "init.h"
diff --git a/util/network/poller.h b/util/network/poller.h
index f305a74976..8dccd73140 100644
--- a/util/network/poller.h
+++ b/util/network/poller.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "socket.h"
diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h
index 6727abe330..e8c7e40fba 100644
--- a/util/network/pollerimpl.h
+++ b/util/network/pollerimpl.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "socket.h"
diff --git a/util/network/sock.h b/util/network/sock.h
index 933a0c8a81..b10be2f715 100644
--- a/util/network/sock.h
+++ b/util/network/sock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/folder/path.h>
#include <util/system/defaults.h>
diff --git a/util/network/socket.h b/util/network/socket.h
index 126ceb6311..40c8648b40 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "init.h"
diff --git a/util/random/entropy.h b/util/random/entropy.h
index 85dee81fa2..62029c1b63 100644
--- a/util/random/entropy.h
+++ b/util/random/entropy.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
class TBuffer;
class IInputStream;
diff --git a/util/random/mersenne.h b/util/random/mersenne.h
index ab55a6d063..b2044604ac 100644
--- a/util/random/mersenne.h
+++ b/util/random/mersenne.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "mersenne64.h"
#include "mersenne32.h"
diff --git a/util/random/mersenne32.h b/util/random/mersenne32.h
index c4c9e3d2e9..861f3a3d38 100644
--- a/util/random/mersenne32.h
+++ b/util/random/mersenne32.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
diff --git a/util/random/mersenne64.h b/util/random/mersenne64.h
index 1639cfc88c..12ca43b6af 100644
--- a/util/random/mersenne64.h
+++ b/util/random/mersenne64.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
diff --git a/util/random/random.h b/util/random/random.h
index be1c26e272..16b52d3995 100644
--- a/util/random/random.h
+++ b/util/random/random.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
/*
* thread-safe random number generator.
@@ -13,9 +13,9 @@
template <class T>
T RandomNumber();
-/*
- * returns value in range [0, max)
- */
+/*
+ * returns value in range [0, max)
+ */
template <class T>
T RandomNumber(T max);
diff --git a/util/random/shuffle.h b/util/random/shuffle.h
index 339864217c..274ac147c9 100644
--- a/util/random/shuffle.h
+++ b/util/random/shuffle.h
@@ -1,14 +1,14 @@
-#pragma once
-
+#pragma once
+
#include "fast.h"
#include "entropy.h"
-#include <util/generic/utility.h>
+#include <util/generic/utility.h>
// some kind of https://en.wikipedia.org/wiki/Fisher–Yates_shuffle#The_modern_algorithm
template <typename TRandIter, typename TRandIterEnd>
-inline void Shuffle(TRandIter begin, TRandIterEnd end) {
+inline void Shuffle(TRandIter begin, TRandIterEnd end) {
static_assert(sizeof(end - begin) <= sizeof(size_t), "fixme");
static_assert(sizeof(TReallyFastRng32::RandMax()) <= sizeof(size_t), "fixme");
@@ -16,8 +16,8 @@ inline void Shuffle(TRandIter begin, TRandIterEnd end) {
Shuffle(begin, end, TReallyFastRng32(Seed()));
} else {
Shuffle(begin, end, TFastRng64(Seed()));
- }
-}
+ }
+}
template <typename TRandIter, typename TRandIterEnd, typename TRandGen>
inline void Shuffle(TRandIter begin, TRandIterEnd end, TRandGen&& gen) {
diff --git a/util/random/shuffle_ut.cpp b/util/random/shuffle_ut.cpp
index 4d2415557e..87cbae94c0 100644
--- a/util/random/shuffle_ut.cpp
+++ b/util/random/shuffle_ut.cpp
@@ -3,23 +3,23 @@
#include "mersenne.h"
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/ylimits.h>
-
+
+#include <util/generic/ylimits.h>
+
Y_UNIT_TEST_SUITE(TRandUtilsTest) {
template <typename... A>
static void TestRange(A&&... args) {
TString s0, s1;
ShuffleRange(s1, args...);
- s1 = "0";
+ s1 = "0";
ShuffleRange(s1, args...);
- s1 = "01";
+ s1 = "01";
ShuffleRange(s1, args...);
- s1 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- s0 = s1.copy();
+ s1 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ s0 = s1.copy();
ShuffleRange(s1, args...);
- UNIT_ASSERT(s0 != s1); // if shuffle does work, chances it will fail are 1 to 64!.
- }
+ UNIT_ASSERT(s0 != s1); // if shuffle does work, chances it will fail are 1 to 64!.
+ }
template <typename... A>
static void TestIter(A&&... args) {
@@ -72,4 +72,4 @@ Y_UNIT_TEST_SUITE(TRandUtilsTest) {
TestIter(prng);
}
-}
+}
diff --git a/util/str_stl.h b/util/str_stl.h
index 616e87cb84..f1e137181d 100644
--- a/util/str_stl.h
+++ b/util/str_stl.h
@@ -1,10 +1,10 @@
-#pragma once
+#pragma once
#include <util/memory/alloc.h>
#include <util/digest/numeric.h>
#include <util/generic/string.h>
#include <util/generic/string_hash.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
#include <functional>
diff --git a/util/stream/aligned.h b/util/stream/aligned.h
index 5c86beddc6..70e7be05a9 100644
--- a/util/stream/aligned.h
+++ b/util/stream/aligned.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "input.h"
#include "output.h"
diff --git a/util/stream/buffer.h b/util/stream/buffer.h
index 4ca6128d80..9dc99dbe49 100644
--- a/util/stream/buffer.h
+++ b/util/stream/buffer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
#include "zerocopy_output.h"
diff --git a/util/stream/buffered.h b/util/stream/buffered.h
index 42405d326c..0847186141 100644
--- a/util/stream/buffered.h
+++ b/util/stream/buffered.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
#include "zerocopy_output.h"
diff --git a/util/stream/debug.h b/util/stream/debug.h
index cbee0ee770..92d6d4b42d 100644
--- a/util/stream/debug.h
+++ b/util/stream/debug.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "output.h"
diff --git a/util/stream/file.h b/util/stream/file.h
index eee86658df..c1cf4f591d 100644
--- a/util/stream/file.h
+++ b/util/stream/file.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "input.h"
diff --git a/util/stream/format.h b/util/stream/format.h
index 04257f5a81..b033208a1b 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "mem.h"
#include "output.h"
diff --git a/util/stream/input.cpp b/util/stream/input.cpp
index 5f545c2bca..6e8170f2f9 100644
--- a/util/stream/input.cpp
+++ b/util/stream/input.cpp
@@ -120,9 +120,9 @@ TString IInputStream::ReadTo(char ch) {
}
size_t IInputStream::Skip(size_t sz) {
- return DoSkip(sz);
-}
-
+ return DoSkip(sz);
+}
+
size_t IInputStream::DoSkip(size_t sz) {
if (sz < 128) {
return Load(alloca(sz), sz);
@@ -143,8 +143,8 @@ size_t IInputStream::DoSkip(size_t sz) {
}
return total;
-}
-
+}
+
TString IInputStream::ReadAll() {
TString result;
TStringOutput stream(result);
diff --git a/util/stream/input.h b/util/stream/input.h
index 59874fd06e..f0d5807ed2 100644
--- a/util/stream/input.h
+++ b/util/stream/input.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
#include <util/generic/noncopyable.h>
diff --git a/util/stream/length.cpp b/util/stream/length.cpp
index 09968fc2ab..9907fe2ac9 100644
--- a/util/stream/length.cpp
+++ b/util/stream/length.cpp
@@ -1,32 +1,32 @@
-#include "length.h"
-
-size_t TLengthLimitedInput::DoRead(void* buf, size_t len) {
- const size_t toRead = (size_t)Min<ui64>(Length_, len);
- const size_t ret = Slave_->Read(buf, toRead);
-
- Length_ -= ret;
-
- return ret;
-}
-
-size_t TLengthLimitedInput::DoSkip(size_t len) {
- len = (size_t)Min<ui64>((ui64)len, Length_);
- len = Slave_->Skip(len);
- Length_ -= len;
- return len;
-}
-
-size_t TCountingInput::DoRead(void* buf, size_t len) {
- const size_t ret = Slave_->Read(buf, len);
- Count_ += ret;
- return ret;
-}
-
-size_t TCountingInput::DoSkip(size_t len) {
- const size_t ret = Slave_->Skip(len);
- Count_ += ret;
- return ret;
-}
+#include "length.h"
+
+size_t TLengthLimitedInput::DoRead(void* buf, size_t len) {
+ const size_t toRead = (size_t)Min<ui64>(Length_, len);
+ const size_t ret = Slave_->Read(buf, toRead);
+
+ Length_ -= ret;
+
+ return ret;
+}
+
+size_t TLengthLimitedInput::DoSkip(size_t len) {
+ len = (size_t)Min<ui64>((ui64)len, Length_);
+ len = Slave_->Skip(len);
+ Length_ -= len;
+ return len;
+}
+
+size_t TCountingInput::DoRead(void* buf, size_t len) {
+ const size_t ret = Slave_->Read(buf, len);
+ Count_ += ret;
+ return ret;
+}
+
+size_t TCountingInput::DoSkip(size_t len) {
+ const size_t ret = Slave_->Skip(len);
+ Count_ += ret;
+ return ret;
+}
size_t TCountingInput::DoReadTo(TString& st, char ch) {
const size_t ret = Slave_->ReadTo(st, ch);
diff --git a/util/stream/length.h b/util/stream/length.h
index 7d8e1c4a09..4d508ae24d 100644
--- a/util/stream/length.h
+++ b/util/stream/length.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "input.h"
#include "output.h"
@@ -13,58 +13,58 @@
* treat these as separate streams.
*/
class TLengthLimitedInput: public IInputStream {
-public:
+public:
inline TLengthLimitedInput(IInputStream* slave, ui64 length) noexcept
: Slave_(slave)
, Length_(length)
{
- }
+ }
~TLengthLimitedInput() override = default;
inline ui64 Left() const noexcept {
- return Length_;
- }
+ return Length_;
+ }
-private:
+private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
-private:
+private:
IInputStream* Slave_;
- ui64 Length_;
-};
+ ui64 Length_;
+};
/**
* Proxy input stream that counts the number of characters read.
*/
class TCountingInput: public IInputStream {
-public:
+public:
inline TCountingInput(IInputStream* slave) noexcept
: Slave_(slave)
, Count_()
{
- }
-
+ }
+
~TCountingInput() override = default;
-
+
/**
* \returns The total number of characters read from
* this stream.
*/
inline ui64 Counter() const noexcept {
- return Count_;
- }
-
-private:
+ return Count_;
+ }
+
+private:
size_t DoRead(void* buf, size_t len) override;
size_t DoSkip(size_t len) override;
size_t DoReadTo(TString& st, char ch) override;
ui64 DoReadAll(IOutputStream& out) override;
-
-private:
+
+private:
IInputStream* Slave_;
- ui64 Count_;
+ ui64 Count_;
};
/**
diff --git a/util/stream/mem.h b/util/stream/mem.h
index 5dd475deb9..18a5d46772 100644
--- a/util/stream/mem.h
+++ b/util/stream/mem.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
#include "zerocopy_output.h"
diff --git a/util/stream/multi.h b/util/stream/multi.h
index 6c62501139..8bfd462d99 100644
--- a/util/stream/multi.h
+++ b/util/stream/multi.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "input.h"
diff --git a/util/stream/null.h b/util/stream/null.h
index 87c5bd9470..8c335a9a78 100644
--- a/util/stream/null.h
+++ b/util/stream/null.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
#include "output.h"
diff --git a/util/stream/output.h b/util/stream/output.h
index 29d43d4c25..00eef50b95 100644
--- a/util/stream/output.h
+++ b/util/stream/output.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "labeled.h"
diff --git a/util/stream/pipe.h b/util/stream/pipe.h
index 3f96fa5cc0..18525b9517 100644
--- a/util/stream/pipe.h
+++ b/util/stream/pipe.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "input.h"
#include "output.h"
diff --git a/util/stream/printf.h b/util/stream/printf.h
index 7067f7eae4..1c7ddc0664 100644
--- a/util/stream/printf.h
+++ b/util/stream/printf.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/compat.h>
diff --git a/util/stream/str.h b/util/stream/str.h
index 1d1e99980d..028bd572c0 100644
--- a/util/stream/str.h
+++ b/util/stream/str.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
#include "zerocopy_output.h"
diff --git a/util/stream/tee.h b/util/stream/tee.h
index bf3072f095..c69e232fb9 100644
--- a/util/stream/tee.h
+++ b/util/stream/tee.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "output.h"
diff --git a/util/stream/tempbuf.h b/util/stream/tempbuf.h
index 0e2f2b3040..a6dc001025 100644
--- a/util/stream/tempbuf.h
+++ b/util/stream/tempbuf.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "output.h"
diff --git a/util/stream/tokenizer.h b/util/stream/tokenizer.h
index 6677c3354e..b2398efdd1 100644
--- a/util/stream/tokenizer.h
+++ b/util/stream/tokenizer.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "input.h"
diff --git a/util/stream/walk.h b/util/stream/walk.h
index d972458fdd..7e62cb44dc 100644
--- a/util/stream/walk.h
+++ b/util/stream/walk.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "zerocopy.h"
diff --git a/util/stream/zerocopy.h b/util/stream/zerocopy.h
index 957f6233c1..3315aa3a51 100644
--- a/util/stream/zerocopy.h
+++ b/util/stream/zerocopy.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/yassert.h>
#include <util/system/defaults.h>
diff --git a/util/stream/zlib.h b/util/stream/zlib.h
index 1d4ca35cbb..e7de7c81b7 100644
--- a/util/stream/zlib.h
+++ b/util/stream/zlib.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "input.h"
diff --git a/util/string/cast.h b/util/string/cast.h
index a18a116811..90e925c194 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -1,11 +1,11 @@
-#pragma once
+#pragma once
#include <util/system/defaults.h>
#include <util/stream/str.h>
#include <util/generic/string.h>
#include <util/generic/strbuf.h>
#include <util/generic/typetraits.h>
-#include <util/generic/yexception.h>
+#include <util/generic/yexception.h>
/*
* specialized for all arithmetic types
diff --git a/util/string/escape.cpp b/util/string/escape.cpp
index 3898d6ac69..cd09a7dbd0 100644
--- a/util/string/escape.cpp
+++ b/util/string/escape.cpp
@@ -3,7 +3,7 @@
#include <util/system/defaults.h>
#include <util/charset/utf8.h>
-#include <util/charset/wide.h>
+#include <util/charset/wide.h>
/// @todo: escape trigraphs (eg "??/" is "\")
@@ -168,10 +168,10 @@ TBasicString<TChar>& EscapeCImpl(const TChar* str, size_t len, TBasicString<TCha
if (j > 0) {
r.append(str + j, len - j);
} else {
- r.append(str, len);
+ r.append(str, len);
}
-
- return r;
+
+ return r;
}
template TString& EscapeCImpl<TString::TChar>(const TString::TChar* str, size_t len, TString& r);
@@ -186,23 +186,23 @@ namespace {
WriteUTF8Char(v, sz, (ui8*)buf);
s.AppendNoAlias(buf, sz);
}
-
+
inline void AppendUnicode(TUtf16String& s, wchar32 v) {
WriteSymbol(v, s);
}
-
+
template <ui32 sz, typename TChar>
inline size_t CountHex(const TChar* p, const TChar* pe) {
auto b = p;
auto e = Min(p + sz, pe);
-
+
while (b < e && IsHexDigit(*b)) {
++b;
}
return b - p;
- }
-
+ }
+
template <size_t sz, typename TChar, typename T>
inline bool ParseHex(const TChar* p, const TChar* pe, T& t) noexcept {
return (p + sz <= pe) && TryIntFromString<16>(p, sz, t);
@@ -211,36 +211,36 @@ namespace {
template <ui32 sz, typename TChar>
inline size_t CountOct(const TChar* p, const TChar* pe) {
ui32 maxsz = Min<size_t>(sz, pe - p);
-
+
if (3 == sz && 3 == maxsz && !(*p >= '0' && *p <= '3')) {
maxsz = 2;
}
-
+
for (ui32 i = 0; i < maxsz; ++i, ++p) {
if (!IsOctDigit(*p)) {
return i;
}
}
-
+
return maxsz;
- }
-}
-
+ }
+}
+
template <class TChar, class TStr>
static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) {
const TChar* pe = p + sz;
-
+
while (p != pe) {
- if ('\\' == *p) {
- ++p;
-
+ if ('\\' == *p) {
+ ++p;
+
if (p == pe) {
- return res;
+ return res;
}
-
+
switch (*p) {
default:
- res.append(*p);
+ res.append(*p);
break;
case 'a':
res.append('\a');
@@ -297,7 +297,7 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) {
} else {
res.append(*p);
}
-
+
break;
case '0':
case '1':
@@ -315,7 +315,7 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) {
res.append((TChar)IntFromString<ui32, 8>(p, v));
p += v - 1;
} break;
- }
+ }
++p;
} else {
@@ -325,11 +325,11 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) {
res.append(p, n);
p = n;
}
- }
-
- return res;
-}
-
+ }
+
+ return res;
+}
+
template <class TChar>
TBasicString<TChar>& UnescapeCImpl(const TChar* p, size_t sz, TBasicString<TChar>& res) {
return DoUnescapeC(p, sz, res);
@@ -402,12 +402,12 @@ template size_t UnescapeCCharLen<TUtf16String::TChar>(const TUtf16String::TChar*
TString& EscapeC(const TStringBuf str, TString& s) {
return EscapeC(str.data(), str.size(), s);
-}
-
+}
+
TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& w) {
return EscapeC(str.data(), str.size(), w);
-}
-
+}
+
TString EscapeC(const TString& str) {
return EscapeC(str.data(), str.size());
}
@@ -418,16 +418,16 @@ TUtf16String EscapeC(const TUtf16String& str) {
TString& UnescapeC(const TStringBuf str, TString& s) {
return UnescapeC(str.data(), str.size(), s);
-}
-
+}
+
TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& w) {
return UnescapeC(str.data(), str.size(), w);
-}
-
+}
+
TString UnescapeC(const TStringBuf str) {
return UnescapeC(str.data(), str.size());
-}
-
+}
+
TUtf16String UnescapeC(const TWtringBuf str) {
return UnescapeC(str.data(), str.size());
-}
+}
diff --git a/util/string/escape.h b/util/string/escape.h
index fe69e21edd..b01be65b0e 100644
--- a/util/string/escape.h
+++ b/util/string/escape.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/string.h>
#include <util/generic/strbuf.h>
@@ -6,21 +6,21 @@
template <class TChar>
TBasicString<TChar>& EscapeCImpl(const TChar* str, size_t len, TBasicString<TChar>&);
-template <class TChar>
+template <class TChar>
TBasicString<TChar>& UnescapeCImpl(const TChar* str, size_t len, TBasicString<TChar>&);
-
+
template <class TChar>
TChar* UnescapeC(const TChar* str, size_t len, TChar* buf);
template <typename TChar>
static inline TBasicString<TChar>& EscapeC(const TChar* str, size_t len, TBasicString<TChar>& s) {
- return EscapeCImpl(str, len, s);
-}
-
-template <typename TChar>
+ return EscapeCImpl(str, len, s);
+}
+
+template <typename TChar>
static inline TBasicString<TChar> EscapeC(const TChar* str, size_t len) {
TBasicString<TChar> s;
- return EscapeC(str, len, s);
+ return EscapeC(str, len, s);
}
template <typename TChar>
@@ -30,16 +30,16 @@ static inline TBasicString<TChar> EscapeC(const TBasicStringBuf<TChar>& str) {
template <typename TChar>
static inline TBasicString<TChar>& UnescapeC(const TChar* str, size_t len, TBasicString<TChar>& s) {
- return UnescapeCImpl(str, len, s);
-}
-
-template <typename TChar>
+ return UnescapeCImpl(str, len, s);
+}
+
+template <typename TChar>
static inline TBasicString<TChar> UnescapeC(const TChar* str, size_t len) {
TBasicString<TChar> s;
- return UnescapeCImpl(str, len, s);
-}
-
-template <typename TChar>
+ return UnescapeCImpl(str, len, s);
+}
+
+template <typename TChar>
static inline TBasicString<TChar> EscapeC(TChar ch) {
return EscapeC(&ch, 1);
}
@@ -51,14 +51,14 @@ static inline TBasicString<TChar> EscapeC(const TChar* str) {
TString& EscapeC(const TStringBuf str, TString& res);
TUtf16String& EscapeC(const TWtringBuf str, TUtf16String& res);
-
+
// these two need to be methods, because of TBasicString::Quote implementation
TString EscapeC(const TString& str);
TUtf16String EscapeC(const TUtf16String& str);
-
+
TString& UnescapeC(const TStringBuf str, TString& res);
TUtf16String& UnescapeC(const TWtringBuf str, TUtf16String& res);
-
+
TString UnescapeC(const TStringBuf str);
TUtf16String UnescapeC(const TWtringBuf wtr);
diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp
index 17555e0e0c..cd38ecffd3 100644
--- a/util/string/escape_ut.cpp
+++ b/util/string/escape_ut.cpp
@@ -87,7 +87,7 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
TUtf16String actual2(UnescapeC(expected));
UNIT_ASSERT_VALUES_EQUAL(expected, actual);
- UNIT_ASSERT_VALUES_EQUAL(source, actual2);
+ UNIT_ASSERT_VALUES_EQUAL(source, actual2);
}
UNIT_ASSERT_VALUES_EQUAL(u"http://ya.ru/\\x17\\n\\u1234", EscapeC(u"http://ya.ru/\x17\n\u1234"));
diff --git a/util/string/hex.h b/util/string/hex.h
index bfe5c9a785..af3d2d528f 100644
--- a/util/string/hex.h
+++ b/util/string/hex.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/string.h>
#include <util/generic/yexception.h>
diff --git a/util/string/split.h b/util/string/split.h
index e6190ceafe..bc46d9e64c 100644
--- a/util/string/split.h
+++ b/util/string/split.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "strspn.h"
#include "cast.h"
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index 2a966992be..21eccef779 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -1,124 +1,124 @@
-#include "join.h"
+#include "join.h"
#include "subst.h"
#include <string>
#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TStringSubst) {
- static const size_t MIN_FROM_CTX = 4;
+ static const size_t MIN_FROM_CTX = 4;
static const TVector<TString> ALL_FROM{TString("F"), TString("FF")};
static const TVector<TString> ALL_TO{TString(""), TString("T"), TString("TT"), TString("TTT")};
-
+
static void AssertSubstGlobal(const TString& sFrom, const TString& sTo, const TString& from, const TString& to, const size_t fromPos, const size_t numSubst) {
TString s = sFrom;
- size_t res = SubstGlobal(s, from, to, fromPos);
- UNIT_ASSERT_VALUES_EQUAL_C(res, numSubst,
- TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
- if (numSubst) {
- UNIT_ASSERT_STRINGS_EQUAL_C(s, sTo,
- TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
- } else {
- // ensure s didn't trigger copy-on-write
- UNIT_ASSERT_VALUES_EQUAL_C(s.c_str(), sFrom.c_str(),
- TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
- }
- }
-
+ size_t res = SubstGlobal(s, from, to, fromPos);
+ UNIT_ASSERT_VALUES_EQUAL_C(res, numSubst,
+ TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
+ if (numSubst) {
+ UNIT_ASSERT_STRINGS_EQUAL_C(s, sTo,
+ TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
+ } else {
+ // ensure s didn't trigger copy-on-write
+ UNIT_ASSERT_VALUES_EQUAL_C(s.c_str(), sFrom.c_str(),
+ TStringBuilder() << "numSubst=" << numSubst << ", fromPos=" << fromPos << ", " << sFrom << " -> " << sTo);
+ }
+ }
+
Y_UNIT_TEST(TestSubstGlobalNoSubstA) {
- for (const auto& from : ALL_FROM) {
+ for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
- const size_t minSz = fromSz;
- const size_t maxSz = fromSz + MIN_FROM_CTX;
- for (size_t sz = minSz; sz <= maxSz; ++sz) {
- for (size_t fromPos = 0; fromPos < sz; ++fromPos) {
+ const size_t minSz = fromSz;
+ const size_t maxSz = fromSz + MIN_FROM_CTX;
+ for (size_t sz = minSz; sz <= maxSz; ++sz) {
+ for (size_t fromPos = 0; fromPos < sz; ++fromPos) {
TString s{sz, '.'};
- for (const auto& to : ALL_TO) {
- AssertSubstGlobal(s, s, from, to, fromPos, 0);
- }
- }
- }
- }
- }
-
+ for (const auto& to : ALL_TO) {
+ AssertSubstGlobal(s, s, from, to, fromPos, 0);
+ }
+ }
+ }
+ }
+ }
+
Y_UNIT_TEST(TestSubstGlobalNoSubstB) {
- for (const auto& from : ALL_FROM) {
+ for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
- const size_t minSz = fromSz;
- const size_t maxSz = fromSz + MIN_FROM_CTX;
- for (size_t sz = minSz; sz <= maxSz; ++sz) {
- for (size_t fromPos = 0; fromPos <= sz - fromSz; ++fromPos) {
- for (size_t fromBeg = 0; fromBeg < fromPos; ++fromBeg) {
- const auto parts = {
+ const size_t minSz = fromSz;
+ const size_t maxSz = fromSz + MIN_FROM_CTX;
+ for (size_t sz = minSz; sz <= maxSz; ++sz) {
+ for (size_t fromPos = 0; fromPos <= sz - fromSz; ++fromPos) {
+ for (size_t fromBeg = 0; fromBeg < fromPos; ++fromBeg) {
+ const auto parts = {
TString{fromBeg, '.'},
TString{sz - fromSz - fromBeg, '.'}};
TString s = JoinSeq(from, parts);
- for (const auto& to : ALL_TO) {
- AssertSubstGlobal(s, s, from, to, fromPos, 0);
- }
- }
- }
- }
- }
- }
-
+ for (const auto& to : ALL_TO) {
+ AssertSubstGlobal(s, s, from, to, fromPos, 0);
+ }
+ }
+ }
+ }
+ }
+ }
+
static void DoTestSubstGlobal(TVector<TString>& parts, const size_t minBeg, const size_t sz,
const TString& from, const size_t fromPos, const size_t numSubst) {
- const size_t numLeft = numSubst - parts.size();
+ const size_t numLeft = numSubst - parts.size();
for (size_t fromBeg = minBeg; fromBeg <= sz - numLeft * from.size(); ++fromBeg) {
- if (parts.empty()) {
- parts.emplace_back(fromBeg, '.');
- } else {
- parts.emplace_back(fromBeg - minBeg, '.');
- }
-
- if (numLeft == 1) {
+ if (parts.empty()) {
+ parts.emplace_back(fromBeg, '.');
+ } else {
+ parts.emplace_back(fromBeg - minBeg, '.');
+ }
+
+ if (numLeft == 1) {
parts.emplace_back(sz - fromBeg - from.size(), '.');
TString sFrom = JoinSeq(from, parts);
UNIT_ASSERT_VALUES_EQUAL_C(sFrom.size(), sz, sFrom);
- for (const auto& to : ALL_TO) {
+ for (const auto& to : ALL_TO) {
TString sTo = JoinSeq(to, parts);
- AssertSubstGlobal(sFrom, sTo, from, to, fromPos, numSubst);
- }
- parts.pop_back();
- } else {
+ AssertSubstGlobal(sFrom, sTo, from, to, fromPos, numSubst);
+ }
+ parts.pop_back();
+ } else {
DoTestSubstGlobal(parts, fromBeg + from.size(), sz, from, fromPos, numSubst);
- }
-
- parts.pop_back();
- }
- }
-
- static void DoTestSubstGlobal(size_t numSubst) {
+ }
+
+ parts.pop_back();
+ }
+ }
+
+ static void DoTestSubstGlobal(size_t numSubst) {
TVector<TString> parts;
- for (const auto& from : ALL_FROM) {
+ for (const auto& from : ALL_FROM) {
const size_t fromSz = from.size();
- const size_t minSz = numSubst * fromSz;
- const size_t maxSz = numSubst * (fromSz + MIN_FROM_CTX);
- for (size_t sz = minSz; sz <= maxSz; ++sz) {
- const size_t maxPos = sz - numSubst * fromSz;
- for (size_t fromPos = 0; fromPos <= maxPos; ++fromPos) {
- DoTestSubstGlobal(parts, fromPos, sz, from, fromPos, numSubst);
- }
- }
- }
- }
-
+ const size_t minSz = numSubst * fromSz;
+ const size_t maxSz = numSubst * (fromSz + MIN_FROM_CTX);
+ for (size_t sz = minSz; sz <= maxSz; ++sz) {
+ const size_t maxPos = sz - numSubst * fromSz;
+ for (size_t fromPos = 0; fromPos <= maxPos; ++fromPos) {
+ DoTestSubstGlobal(parts, fromPos, sz, from, fromPos, numSubst);
+ }
+ }
+ }
+ }
+
Y_UNIT_TEST(TestSubstGlobalSubst1) {
- DoTestSubstGlobal(1);
- }
-
+ DoTestSubstGlobal(1);
+ }
+
Y_UNIT_TEST(TestSubstGlobalSubst2) {
- DoTestSubstGlobal(2);
- }
-
+ DoTestSubstGlobal(2);
+ }
+
Y_UNIT_TEST(TestSubstGlobalSubst3) {
- DoTestSubstGlobal(3);
- }
-
+ DoTestSubstGlobal(3);
+ }
+
Y_UNIT_TEST(TestSubstGlobalSubst4) {
- DoTestSubstGlobal(4);
- }
-
+ DoTestSubstGlobal(4);
+ }
+
Y_UNIT_TEST(TestSubstGlobalOld) {
TString s;
s = "aaa";
@@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
SubstGlobal(s, " ~ ", " ");
UNIT_ASSERT_EQUAL(s, TString("Москва Париж"));
}
-
+
Y_UNIT_TEST(TestSubstGlobalOldRet) {
const TString s1 = "aaa";
const TString s2 = SubstGlobalCopy(s1, "a", "bb");
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index 60cb35e6a5..03e7af62bd 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -20,11 +20,11 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(IsTrue("true"));
UNIT_ASSERT(IsTrue("t"));
UNIT_ASSERT(IsTrue("da"));
-
+
UNIT_ASSERT(!IsTrue(""));
UNIT_ASSERT(!IsTrue("tr"));
UNIT_ASSERT(!IsTrue("foobar"));
- }
+ }
Y_UNIT_TEST(TestIsFalse) {
UNIT_ASSERT(IsFalse("0"));
diff --git a/util/string/util.h b/util/string/util.h
index cd1fa56429..0d77a5042b 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
//THIS FILE A COMPAT STUB HEADER
@@ -8,7 +8,7 @@
#include <util/system/defaults.h>
#include <util/generic/string.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
/// @addtogroup Strings_Miscellaneous
/// @{
diff --git a/util/string/vector.h b/util/string/vector.h
index 59769fd92e..e36c348bbe 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "cast.h"
#include "split.h"
diff --git a/util/system/align.h b/util/system/align.h
index 5e9d07c50d..ea0bbc5b46 100644
--- a/util/system/align.h
+++ b/util/system/align.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "yassert.h"
#include "defaults.h"
diff --git a/util/system/atexit.h b/util/system/atexit.h
index 430f3fc843..eb3188615c 100644
--- a/util/system/atexit.h
+++ b/util/system/atexit.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/atomic.h b/util/system/atomic.h
index 968bc581a4..80265babfd 100644
--- a/util/system/atomic.h
+++ b/util/system/atomic.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h
index ddc85a7234..ed8dc2bdc5 100644
--- a/util/system/atomic_gcc.h
+++ b/util/system/atomic_gcc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define ATOMIC_COMPILER_BARRIER() __asm__ __volatile__("" \
: \
diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h
index 079e5ade11..65c290e6cc 100644
--- a/util/system/atomic_win.h
+++ b/util/system/atomic_win.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <intrin.h>
diff --git a/util/system/backtrace.h b/util/system/backtrace.h
index 8b45980b59..2fce7585c3 100644
--- a/util/system/backtrace.h
+++ b/util/system/backtrace.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
#include <util/system/defaults.h>
diff --git a/util/system/byteorder.h b/util/system/byteorder.h
index a723e66864..94b9fea515 100644
--- a/util/system/byteorder.h
+++ b/util/system/byteorder.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/compat.h b/util/system/compat.h
index 22dcdf224e..c53dbcca17 100644
--- a/util/system/compat.h
+++ b/util/system/compat.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/condvar.h b/util/system/condvar.h
index 4f1a24bf20..569162717c 100644
--- a/util/system/condvar.h
+++ b/util/system/condvar.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "mutex.h"
diff --git a/util/system/context.h b/util/system/context.h
index 332e5757e5..d2a349bfc5 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "align.h"
#include "defaults.h"
diff --git a/util/system/context_i686.h b/util/system/context_i686.h
index 02e54c92db..1abfd5dada 100644
--- a/util/system/context_i686.h
+++ b/util/system/context_i686.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define MJB_BP 3
#define MJB_SP 4
diff --git a/util/system/context_x86.h b/util/system/context_x86.h
index 6532865da6..6ea066ff88 100644
--- a/util/system/context_x86.h
+++ b/util/system/context_x86.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#if defined(_x86_64_)
#include "context_x86_64.h"
diff --git a/util/system/context_x86_64.h b/util/system/context_x86_64.h
index 3b3b804357..94e4f37eb3 100644
--- a/util/system/context_x86_64.h
+++ b/util/system/context_x86_64.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#define MJB_RBP 1
#define MJB_RSP 6
diff --git a/util/system/daemon.h b/util/system/daemon.h
index d8f0b85c2e..b00793b9c9 100644
--- a/util/system/daemon.h
+++ b/util/system/daemon.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
namespace NDaemonMaker {
enum ECloseDescriptors {
diff --git a/util/system/datetime.h b/util/system/datetime.h
index ef9799812e..aa009974e0 100644
--- a/util/system/datetime.h
+++ b/util/system/datetime.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
#include "platform.h"
diff --git a/util/system/defaults.h b/util/system/defaults.h
index 46865de3ef..dcd7abea38 100644
--- a/util/system/defaults.h
+++ b/util/system/defaults.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "platform.h"
diff --git a/util/system/dynlib.h b/util/system/dynlib.h
index 256aad176d..66eaf4a5c1 100644
--- a/util/system/dynlib.h
+++ b/util/system/dynlib.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/error.h b/util/system/error.h
index 1edded460a..5f2d4cc547 100644
--- a/util/system/error.h
+++ b/util/system/error.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/event.h b/util/system/event.h
index 833e8d5a70..cab2fc478a 100644
--- a/util/system/event.h
+++ b/util/system/event.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/ptr.h>
#include <util/datetime/base.h>
diff --git a/util/system/execpath.h b/util/system/execpath.h
index fb42c9f11c..4b914b8e85 100644
--- a/util/system/execpath.h
+++ b/util/system/execpath.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 3e2e9eebd1..057a814f0a 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -1,21 +1,21 @@
#include "dynlib.h"
#include "fasttime.h"
-
-#include <util/generic/singleton.h>
-#include <util/generic/yexception.h>
+
+#include <util/generic/singleton.h>
+#include <util/generic/yexception.h>
#include <utility>
#include <util/thread/singleton.h>
-
+
#if defined(_win_) || defined(_arm32_) || defined(_cygwin_)
-ui64 InterpolatedMicroSeconds() {
- return MicroSeconds();
-}
-#else
-
+ui64 InterpolatedMicroSeconds() {
+ return MicroSeconds();
+}
+#else
+
#include <dlfcn.h>
#include <sys/time.h>
-
+
#if defined(_musl_)
#include <util/generic/hash.h>
#include <util/generic/vector.h>
@@ -24,219 +24,219 @@ ui64 InterpolatedMicroSeconds() {
#include <contrib/libs/linuxvdso/interface.h>
#endif
-namespace {
+namespace {
using TTime = ui64;
-
- struct TSymbols {
+
+ struct TSymbols {
using TFunc = int (*)(struct timeval*, struct timezone*);
-
- inline TSymbols()
+
+ inline TSymbols()
: Func(nullptr)
- {
+ {
// not DEFAULT, cause library/cpp/gettimeofday
Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday"));
-
+
#if defined(_musl_)
- if (!Func) {
+ if (!Func) {
Func = reinterpret_cast<TFunc>(NVdso::Function("__vdso_gettimeofday", "LINUX_2.6"));
}
#endif
if (!Func) {
Func = reinterpret_cast<TFunc>(Libc()->Sym("gettimeofday"));
- }
- }
-
- inline TTime SystemTime() {
- timeval tv;
-
- Zero(tv);
-
+ }
+ }
+
+ inline TTime SystemTime() {
+ timeval tv;
+
+ Zero(tv);
+
Func(&tv, nullptr);
-
- return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
- }
-
+
+ return (((TTime)1000000) * (TTime)tv.tv_sec) + (TTime)tv.tv_usec;
+ }
+
static inline THolder<TDynamicLibrary> OpenLibc() {
- const char* libs[] = {
+ const char* libs[] = {
"/lib/libc.so.8",
"/lib/libc.so.7",
"/lib/libc.so.6",
};
-
+
for (auto& lib : libs) {
- try {
+ try {
return MakeHolder<TDynamicLibrary>(lib);
- } catch (...) {
+ } catch (...) {
// ¯\_(ツ)_/¯
- }
- }
-
- ythrow yexception() << "can not load libc";
- }
-
- inline TDynamicLibrary* Libc() {
- if (!Lib) {
- Lib = OpenLibc();
- }
-
- return Lib.Get();
- }
-
+ }
+ }
+
+ ythrow yexception() << "can not load libc";
+ }
+
+ inline TDynamicLibrary* Libc() {
+ if (!Lib) {
+ Lib = OpenLibc();
+ }
+
+ return Lib.Get();
+ }
+
THolder<TDynamicLibrary> Lib;
- TFunc Func;
- };
-
- static inline TTime SystemTime() {
- return Singleton<TSymbols>()->SystemTime();
- }
-
- struct TInitialTimes {
- inline TInitialTimes()
- : ITime(TimeBase())
- , IProc(RdtscBase())
- {
- }
-
- static TTime RdtscBase() {
- return GetCycleCount() / (TTime)1000;
- }
-
- static TTime TimeBase() {
- return SystemTime();
- }
-
- inline TTime Rdtsc() {
- return RdtscBase() - IProc;
- }
-
- inline TTime Time() {
- return TimeBase() - ITime;
- }
-
- const TTime ITime;
- const TTime IProc;
- };
-
- template <size_t N, class A, class B>
- class TLinePredictor {
- public:
+ TFunc Func;
+ };
+
+ static inline TTime SystemTime() {
+ return Singleton<TSymbols>()->SystemTime();
+ }
+
+ struct TInitialTimes {
+ inline TInitialTimes()
+ : ITime(TimeBase())
+ , IProc(RdtscBase())
+ {
+ }
+
+ static TTime RdtscBase() {
+ return GetCycleCount() / (TTime)1000;
+ }
+
+ static TTime TimeBase() {
+ return SystemTime();
+ }
+
+ inline TTime Rdtsc() {
+ return RdtscBase() - IProc;
+ }
+
+ inline TTime Time() {
+ return TimeBase() - ITime;
+ }
+
+ const TTime ITime;
+ const TTime IProc;
+ };
+
+ template <size_t N, class A, class B>
+ class TLinePredictor {
+ public:
using TSample = std::pair<A, B>;
-
- inline TLinePredictor()
- : C_(0)
- , A_(0)
- , B_(0)
- {
- }
-
+
+ inline TLinePredictor()
+ : C_(0)
+ , A_(0)
+ , B_(0)
+ {
+ }
+
inline void Add(const A& a, const B& b) noexcept {
- Add(TSample(a, b));
- }
-
+ Add(TSample(a, b));
+ }
+
inline void Add(const TSample& s) noexcept {
- S_[(C_++) % N] = s;
+ S_[(C_++) % N] = s;
if (C_ > 1) {
ReCalc();
}
- }
-
+ }
+
inline B Predict(A a) const noexcept {
- return A_ + a * B_;
- }
-
+ return A_ + a * B_;
+ }
+
inline size_t Size() const noexcept {
- return C_;
- }
-
+ return C_;
+ }
+
inline bool Enough() const noexcept {
- return Size() >= N;
- }
-
+ return Size() >= N;
+ }
+
inline A LastX() const noexcept {
- return S_[(C_ - 1) % N].first;
- }
-
- private:
+ return S_[(C_ - 1) % N].first;
+ }
+
+ private:
inline void ReCalc() noexcept {
- const size_t n = Min(N, C_);
-
- double sx = 0;
- double sy = 0;
- double sxx = 0;
- double syy = 0;
- double sxy = 0;
-
- for (size_t i = 0; i < n; ++i) {
- const double x = S_[i].first;
- const double y = S_[i].second;
-
- sx += x;
- sy += y;
- sxx += x * x;
- syy += y * y;
- sxy += x * y;
- }
-
- B_ = (n * sxy - sx * sy) / (n * sxx - sx * sx);
+ const size_t n = Min(N, C_);
+
+ double sx = 0;
+ double sy = 0;
+ double sxx = 0;
+ double syy = 0;
+ double sxy = 0;
+
+ for (size_t i = 0; i < n; ++i) {
+ const double x = S_[i].first;
+ const double y = S_[i].second;
+
+ sx += x;
+ sy += y;
+ sxx += x * x;
+ syy += y * y;
+ sxy += x * y;
+ }
+
+ B_ = (n * sxy - sx * sy) / (n * sxx - sx * sx);
A_ = (sy - B_ * sx) / n;
- }
-
- private:
- size_t C_;
- TSample S_[N];
- double A_;
- double B_;
- };
-
- class TTimePredictor: public TInitialTimes {
- public:
- inline TTimePredictor()
- : Next_(1)
- {
- }
-
- inline TTime Get() {
- return GetBase() + ITime;
- }
-
- private:
- inline TTime GetBase() {
- const TTime x = Rdtsc();
-
- if (TimeToSync(x)) {
- const TTime y = Time();
-
- P_.Add(x, y);
-
- return y;
- }
-
- if (P_.Enough()) {
- return P_.Predict(x);
- }
-
- return Time();
- }
-
- inline bool TimeToSync(TTime x) {
- if (x > Next_) {
- Next_ = Min(x + x / 10, x + 1000000);
-
- return true;
- }
-
- return false;
- }
-
- private:
- TLinePredictor<16, TTime, TTime> P_;
- TTime Next_;
- };
-}
-
-ui64 InterpolatedMicroSeconds() {
+ }
+
+ private:
+ size_t C_;
+ TSample S_[N];
+ double A_;
+ double B_;
+ };
+
+ class TTimePredictor: public TInitialTimes {
+ public:
+ inline TTimePredictor()
+ : Next_(1)
+ {
+ }
+
+ inline TTime Get() {
+ return GetBase() + ITime;
+ }
+
+ private:
+ inline TTime GetBase() {
+ const TTime x = Rdtsc();
+
+ if (TimeToSync(x)) {
+ const TTime y = Time();
+
+ P_.Add(x, y);
+
+ return y;
+ }
+
+ if (P_.Enough()) {
+ return P_.Predict(x);
+ }
+
+ return Time();
+ }
+
+ inline bool TimeToSync(TTime x) {
+ if (x > Next_) {
+ Next_ = Min(x + x / 10, x + 1000000);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private:
+ TLinePredictor<16, TTime, TTime> P_;
+ TTime Next_;
+ };
+}
+
+ui64 InterpolatedMicroSeconds() {
return FastTlsSingleton<TTimePredictor>()->Get();
-}
-
-#endif
+}
+
+#endif
diff --git a/util/system/fasttime.h b/util/system/fasttime.h
index 1515185dd9..544cb4bd19 100644
--- a/util/system/fasttime.h
+++ b/util/system/fasttime.h
@@ -1,6 +1,6 @@
-#pragma once
-
-#include "datetime.h"
-
-/// Fast but possibly less accurate microseconds since epoch
-ui64 InterpolatedMicroSeconds();
+#pragma once
+
+#include "datetime.h"
+
+/// Fast but possibly less accurate microseconds since epoch
+ui64 InterpolatedMicroSeconds();
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 8b9779728c..4a261d020c 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -1098,10 +1098,10 @@ TFile::TFile(FHANDLE fd)
}
TFile::TFile(FHANDLE fd, const TString& name)
- : Impl_(new TImpl(fd, name))
-{
-}
-
+ : Impl_(new TImpl(fd, name))
+{
+}
+
TFile::TFile(const TString& fName, EOpenMode oMode)
: Impl_(new TImpl(fName, oMode))
{
diff --git a/util/system/file.h b/util/system/file.h
index 815805cd8c..9502e159b6 100644
--- a/util/system/file.h
+++ b/util/system/file.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fhandle.h"
#include "flock.h"
diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp
index 3f3536e383..7454a4cb94 100644
--- a/util/system/filemap.cpp
+++ b/util/system/filemap.cpp
@@ -1,5 +1,5 @@
#include "info.h"
-#include "madvise.h"
+#include "madvise.h"
#include "defaults.h"
#include "hi_lo.h"
@@ -288,14 +288,14 @@ public:
void SetSequential() {
#if defined(_unix_)
- if (!(Mode_ & oNotGreedy) && Length_) {
- MadviseSequentialAccess(PtrStart_, Length_);
- }
+ if (!(Mode_ & oNotGreedy) && Length_) {
+ MadviseSequentialAccess(PtrStart_, Length_);
+ }
#endif
}
void Evict(void* ptr, size_t len) {
- MadviseEvict(ptr, len);
+ MadviseEvict(ptr, len);
}
void Evict() {
diff --git a/util/system/filemap.h b/util/system/filemap.h
index 1fa94de67c..11be64bff4 100644
--- a/util/system/filemap.h
+++ b/util/system/filemap.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "file.h"
#include "align.h"
diff --git a/util/system/flock.h b/util/system/flock.h
index e4a401acba..797b1970a1 100644
--- a/util/system/flock.h
+++ b/util/system/flock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "error.h"
#include "defaults.h"
diff --git a/util/system/fs.h b/util/system/fs.h
index ae3c7a75d7..237daf2d2d 100644
--- a/util/system/fs.h
+++ b/util/system/fs.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/flags.h>
#include <util/generic/string.h>
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index df402f0c04..81e98cbc6b 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -2,26 +2,26 @@
#include "file.h"
#include <sys/stat.h>
-
+
#include <util/folder/path.h>
#include <cerrno>
-#if defined(_win_)
+#if defined(_win_)
#include "fs_win.h"
-
+
#ifdef _S_IFLNK
#undef _S_IFLNK
#endif
#define _S_IFLNK 0x80000000
-
+
ui32 GetFileMode(DWORD fileAttributes) {
ui32 mode = 0;
if (fileAttributes == 0xFFFFFFFF)
return mode;
- if (fileAttributes & FILE_ATTRIBUTE_DEVICE)
+ if (fileAttributes & FILE_ATTRIBUTE_DEVICE)
mode |= _S_IFCHR;
- if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+ if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
mode |= _S_IFLNK; // todo: was undefined by the moment of writing this code
if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
mode |= _S_IFDIR;
@@ -31,95 +31,95 @@ ui32 GetFileMode(DWORD fileAttributes) {
mode |= _S_IWRITE;
return mode;
}
-
+
#define S_ISDIR(st_mode) (st_mode & _S_IFDIR)
#define S_ISREG(st_mode) (st_mode & _S_IFREG)
#define S_ISLNK(st_mode) (st_mode & _S_IFLNK)
-
+
using TSystemFStat = BY_HANDLE_FILE_INFORMATION;
-
-#else
-
+
+#else
+
using TSystemFStat = struct stat;
-
+
#endif
-static void MakeStat(TFileStat& st, const TSystemFStat& fs) {
-#ifdef _unix_
- st.Mode = fs.st_mode;
- st.NLinks = fs.st_nlink;
- st.Uid = fs.st_uid;
- st.Gid = fs.st_gid;
- st.Size = fs.st_size;
+static void MakeStat(TFileStat& st, const TSystemFStat& fs) {
+#ifdef _unix_
+ st.Mode = fs.st_mode;
+ st.NLinks = fs.st_nlink;
+ st.Uid = fs.st_uid;
+ st.Gid = fs.st_gid;
+ st.Size = fs.st_size;
st.AllocationSize = fs.st_blocks * 512;
- st.ATime = fs.st_atime;
- st.MTime = fs.st_mtime;
- st.CTime = fs.st_ctime;
+ st.ATime = fs.st_atime;
+ st.MTime = fs.st_mtime;
+ st.CTime = fs.st_ctime;
st.INode = fs.st_ino;
-#else
+#else
timeval tv;
- FileTimeToTimeval(&fs.ftCreationTime, &tv);
+ FileTimeToTimeval(&fs.ftCreationTime, &tv);
st.CTime = tv.tv_sec;
- FileTimeToTimeval(&fs.ftLastAccessTime, &tv);
+ FileTimeToTimeval(&fs.ftLastAccessTime, &tv);
st.ATime = tv.tv_sec;
- FileTimeToTimeval(&fs.ftLastWriteTime, &tv);
+ FileTimeToTimeval(&fs.ftLastWriteTime, &tv);
st.MTime = tv.tv_sec;
- st.NLinks = fs.nNumberOfLinks;
- st.Mode = GetFileMode(fs.dwFileAttributes);
+ st.NLinks = fs.nNumberOfLinks;
+ st.Mode = GetFileMode(fs.dwFileAttributes);
st.Uid = 0;
st.Gid = 0;
- st.Size = ((ui64)fs.nFileSizeHigh << 32) | fs.nFileSizeLow;
+ st.Size = ((ui64)fs.nFileSizeHigh << 32) | fs.nFileSizeLow;
st.AllocationSize = st.Size; // FIXME
st.INode = ((ui64)fs.nFileIndexHigh << 32) | fs.nFileIndexLow;
#endif
-}
-
-static bool GetStatByHandle(TSystemFStat& fs, FHANDLE f) {
-#ifdef _win_
- return GetFileInformationByHandle(f, &fs);
-#else
- return !fstat(f, &fs);
-#endif
-}
-
+}
+
+static bool GetStatByHandle(TSystemFStat& fs, FHANDLE f) {
+#ifdef _win_
+ return GetFileInformationByHandle(f, &fs);
+#else
+ return !fstat(f, &fs);
+#endif
+}
+
static bool GetStatByName(TSystemFStat& fs, const char* fileName, bool nofollow) {
-#ifdef _win_
+#ifdef _win_
TFileHandle h = NFsPrivate::CreateFileWithUtf8Name(fileName, FILE_READ_ATTRIBUTES | FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE,
OPEN_EXISTING,
(nofollow ? FILE_FLAG_OPEN_REPARSE_POINT : 0) | FILE_FLAG_BACKUP_SEMANTICS, true);
if (!h.IsOpen()) {
return false;
}
- return GetStatByHandle(fs, h);
-#else
+ return GetStatByHandle(fs, h);
+#else
return !(nofollow ? lstat : stat)(fileName, &fs);
-#endif
-}
-
+#endif
+}
+
TFileStat::TFileStat() = default;
-
+
TFileStat::TFileStat(const TFile& f) {
- *this = TFileStat(f.GetHandle());
-}
-
+ *this = TFileStat(f.GetHandle());
+}
+
TFileStat::TFileStat(FHANDLE f) {
- TSystemFStat st;
- if (GetStatByHandle(st, f)) {
- MakeStat(*this, st);
- } else {
- *this = TFileStat();
- }
-}
-
+ TSystemFStat st;
+ if (GetStatByHandle(st, f)) {
+ MakeStat(*this, st);
+ } else {
+ *this = TFileStat();
+ }
+}
+
void TFileStat::MakeFromFileName(const char* fileName, bool nofollow) {
- TSystemFStat st;
+ TSystemFStat st;
if (GetStatByName(st, fileName, nofollow)) {
- MakeStat(*this, st);
- } else {
- *this = TFileStat();
- }
-}
-
+ MakeStat(*this, st);
+ } else {
+ *this = TFileStat();
+ }
+}
+
TFileStat::TFileStat(const TFsPath& fileName, bool nofollow) {
MakeFromFileName(fileName.GetPath().data(), nofollow);
}
@@ -137,16 +137,16 @@ bool TFileStat::IsNull() const noexcept {
}
bool TFileStat::IsFile() const noexcept {
- return S_ISREG(Mode);
-}
-
+ return S_ISREG(Mode);
+}
+
bool TFileStat::IsDir() const noexcept {
- return S_ISDIR(Mode);
-}
-
+ return S_ISDIR(Mode);
+}
+
bool TFileStat::IsSymlink() const noexcept {
- return S_ISLNK(Mode);
-}
+ return S_ISLNK(Mode);
+}
bool operator==(const TFileStat& l, const TFileStat& r) noexcept {
return l.Mode == r.Mode &&
diff --git a/util/system/fstat.h b/util/system/fstat.h
index 3c2c5d65c8..64e79e1b55 100644
--- a/util/system/fstat.h
+++ b/util/system/fstat.h
@@ -1,34 +1,34 @@
-#pragma once
-
+#pragma once
+
#include <util/generic/fwd.h>
#include <util/system/fhandle.h>
-
-class TFile;
+
+class TFile;
class TFsPath;
-
-struct TFileStat {
+
+struct TFileStat {
ui32 Mode = 0; /* protection */
ui32 Uid = 0; /* user ID of owner */
ui32 Gid = 0; /* group ID of owner */
-
+
ui64 NLinks = 0; /* number of hard links */
ui64 Size = 0; /* total size, in bytes */
ui64 INode = 0; /* inode number */
ui64 AllocationSize = 0; /* number of bytes allocated on the disk */
-
+
time_t ATime = 0; /* time of last access */
time_t MTime = 0; /* time of last modification */
time_t CTime = 0; /* time of last status change */
-
-public:
- TFileStat();
+
+public:
+ TFileStat();
bool IsNull() const noexcept;
bool IsFile() const noexcept;
bool IsDir() const noexcept;
bool IsSymlink() const noexcept;
-
+
explicit TFileStat(const TFile& f);
explicit TFileStat(FHANDLE f);
TFileStat(const TFsPath& fileName, bool nofollow = false);
@@ -40,7 +40,7 @@ public:
private:
void MakeFromFileName(const char* fileName, bool nofollow);
-};
+};
i64 GetFileLength(FHANDLE fd);
i64 GetFileLength(const char* name);
diff --git a/util/system/guard.h b/util/system/guard.h
index 84c606980f..efc091d5f8 100644
--- a/util/system/guard.h
+++ b/util/system/guard.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/noncopyable.h>
diff --git a/util/system/hostname.h b/util/system/hostname.h
index fe23900ca6..0839ee2b59 100644
--- a/util/system/hostname.h
+++ b/util/system/hostname.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index 5c57099bec..0a4c252ec2 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -1,7 +1,7 @@
-#pragma once
+#pragma once
#include "defaults.h"
-
+
namespace NHPTimer {
using STime = i64;
// May delay for ~50ms to compute frequency
diff --git a/util/system/info.h b/util/system/info.h
index ea456ec661..73ebe48a9a 100644
--- a/util/system/info.h
+++ b/util/system/info.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/madvise.cpp b/util/system/madvise.cpp
index b4d2454146..58c894e3ef 100644
--- a/util/system/madvise.cpp
+++ b/util/system/madvise.cpp
@@ -1,16 +1,16 @@
-#include "madvise.h"
-#include "align.h"
-#include "info.h"
-
-#include <util/generic/yexception.h>
-
-#if defined(_win_)
+#include "madvise.h"
+#include "align.h"
+#include "info.h"
+
+#include <util/generic/yexception.h>
+
+#if defined(_win_)
#include <util/system/winint.h>
-#else
+#else
#include <sys/types.h>
#include <sys/mman.h>
-#endif
-
+#endif
+
#ifndef MADV_DONTDUMP /* This flag is defined in sys/mman.h since Linux 3.4, but currently old libc header is in use \
for capability with Ubuntu 12.04, so we need to define it here manually */
#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, overrides the coredump filter bits */
@@ -21,34 +21,34 @@
#define MADV_DODUMP 17 /* Undo the effect of an earlier MADV_DONTDUMP */
#endif
-namespace {
+namespace {
void Madvise(int flag, const void* cbegin, size_t size) {
- static const size_t pageSize = NSystemInfo::GetPageSize();
- void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
- size = AlignUp(size, pageSize);
-
-#if defined(_win_)
+ static const size_t pageSize = NSystemInfo::GetPageSize();
+ void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
+ size = AlignUp(size, pageSize);
+
+#if defined(_win_)
if (!VirtualFree((LPVOID)begin, size, flag)) {
TString err(LastSystemErrorText());
ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
- }
-#else
+ }
+#else
if (-1 == madvise(begin, size, flag)) {
TString err(LastSystemErrorText());
ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
- }
-#endif
- }
-}
-
-void MadviseSequentialAccess(const void* begin, size_t size) {
+ }
+#endif
+ }
+}
+
+void MadviseSequentialAccess(const void* begin, size_t size) {
#if !defined(_win_)
Madvise(MADV_SEQUENTIAL, begin, size);
#endif
-}
-
+}
+
void MadviseSequentialAccess(TArrayRef<const char> data) {
MadviseSequentialAccess(data.data(), data.size());
}
@@ -57,12 +57,12 @@ void MadviseSequentialAccess(TArrayRef<const ui8> data) {
MadviseSequentialAccess(data.data(), data.size());
}
-void MadviseRandomAccess(const void* begin, size_t size) {
+void MadviseRandomAccess(const void* begin, size_t size) {
#if !defined(_win_)
Madvise(MADV_RANDOM, begin, size);
#endif
-}
-
+}
+
void MadviseRandomAccess(TArrayRef<const char> data) {
MadviseRandomAccess(data.data(), data.size());
}
@@ -71,7 +71,7 @@ void MadviseRandomAccess(TArrayRef<const ui8> data) {
MadviseRandomAccess(data.data(), data.size());
}
-void MadviseEvict(const void* begin, size_t size) {
+void MadviseEvict(const void* begin, size_t size) {
#if defined(_win_)
Madvise(MEM_DECOMMIT, begin, size);
#elif defined(_linux_) || defined(_cygwin_)
@@ -79,7 +79,7 @@ void MadviseEvict(const void* begin, size_t size) {
#else // freebsd, osx
Madvise(MADV_FREE, begin, size);
#endif
-}
+}
void MadviseEvict(TArrayRef<const char> data) {
MadviseEvict(data.data(), data.size());
diff --git a/util/system/madvise.h b/util/system/madvise.h
index 37172703be..606733152e 100644
--- a/util/system/madvise.h
+++ b/util/system/madvise.h
@@ -1,21 +1,21 @@
-#pragma once
-
-#include "defaults.h"
-
+#pragma once
+
+#include "defaults.h"
+
#include <util/generic/array_ref.h>
-/// see linux madvise(MADV_SEQUENTIAL)
-void MadviseSequentialAccess(const void* begin, size_t size);
+/// see linux madvise(MADV_SEQUENTIAL)
+void MadviseSequentialAccess(const void* begin, size_t size);
void MadviseSequentialAccess(TArrayRef<const char> data);
void MadviseSequentialAccess(TArrayRef<const ui8> data);
-
-/// see linux madvise(MADV_RANDOM)
-void MadviseRandomAccess(const void* begin, size_t size);
+
+/// see linux madvise(MADV_RANDOM)
+void MadviseRandomAccess(const void* begin, size_t size);
void MadviseRandomAccess(TArrayRef<const char> data);
void MadviseRandomAccess(TArrayRef<const ui8> data);
-
-/// see linux madvise(MADV_DONTNEED)
-void MadviseEvict(const void* begin, size_t size);
+
+/// see linux madvise(MADV_DONTNEED)
+void MadviseEvict(const void* begin, size_t size);
void MadviseEvict(TArrayRef<const char> data);
void MadviseEvict(TArrayRef<const ui8> data);
diff --git a/util/system/maxlen.h b/util/system/maxlen.h
index 15eab874c0..e1ff7f5008 100644
--- a/util/system/maxlen.h
+++ b/util/system/maxlen.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <cstdlib>
diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp
index 42640022a5..aa51ae3b16 100644
--- a/util/system/mem_info.cpp
+++ b/util/system/mem_info.cpp
@@ -1,15 +1,15 @@
-#include "mem_info.h"
-
-#include <util/generic/strbuf.h>
-#include <util/generic/utility.h>
-#include <util/generic/yexception.h>
-#include <util/stream/file.h>
-#include <util/string/cast.h>
+#include "mem_info.h"
+
+#include <util/generic/strbuf.h>
+#include <util/generic/utility.h>
+#include <util/generic/yexception.h>
+#include <util/stream/file.h>
+#include <util/string/cast.h>
#include <util/string/builder.h>
#include "error.h"
#include "info.h"
-
-#if defined(_unix_)
+
+#if defined(_unix_)
#include <errno.h>
#include <unistd.h>
#if defined(_freebsd_)
@@ -94,20 +94,20 @@ typedef enum _SYSTEM_INFORMATION_CLASS {
SystemProcessInformation = 5,
} SYSTEM_INFORMATION_CLASS;
-#else
-
-#endif
-
-namespace NMemInfo {
+#else
+
+#endif
+
+namespace NMemInfo {
TMemInfo GetMemInfo(pid_t pid) {
TMemInfo result;
-
-#if defined(_unix_)
-
+
+#if defined(_unix_)
+
#if defined(_linux_) || defined(_freebsd_) || defined(_cygwin_)
const ui32 pagesize = NSystemInfo::GetPageSize();
#endif
-
+
#if defined(_linux_) || defined(_cygwin_)
TString path;
if (!pid) {
@@ -129,17 +129,17 @@ namespace NMemInfo {
#elif defined(_freebsd_)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
size_t size = sizeof(struct kinfo_proc);
-
+
struct kinfo_proc proc;
Zero(proc);
-
+
errno = 0;
if (sysctl((int*)mib, 4, &proc, &size, nullptr, 0) == -1) {
int err = errno;
TString errtxt = LastSystemErrorText(err);
ythrow yexception() << "sysctl({CTL_KERN,KERN_PROC,KERN_PROC_PID,pid},4,proc,&size,NULL,0) returned -1, errno: " << err << " (" << errtxt << ")" << Endl;
}
-
+
result.VMS = proc.ki_size;
result.RSS = proc.ki_rssize * pagesize;
#elif defined(_darwin_) && !defined(_arm_) && !defined(__IOS__)
@@ -213,7 +213,7 @@ namespace NMemInfo {
result.VMS = process->VirtualSize;
result.RSS = process->WorkingSetSize;
-#endif
+#endif
return result;
}
-}
+}
diff --git a/util/system/mem_info.h b/util/system/mem_info.h
index b23dbb0d71..f303d49197 100644
--- a/util/system/mem_info.h
+++ b/util/system/mem_info.h
@@ -1,18 +1,18 @@
-#pragma once
-
+#pragma once
+
#include "compat.h"
-
-namespace NMemInfo {
+
+namespace NMemInfo {
struct TMemInfo {
ui64 RSS; // current RAM size of the process
ui64 VMS; // current VM size of the process
-
+
TMemInfo()
: RSS()
, VMS()
{
}
};
-
+
TMemInfo GetMemInfo(pid_t = 0);
-}
+}
diff --git a/util/system/mem_info_ut.cpp b/util/system/mem_info_ut.cpp
index ade1c3367e..a1100ba646 100644
--- a/util/system/mem_info_ut.cpp
+++ b/util/system/mem_info_ut.cpp
@@ -1,21 +1,21 @@
-#include "mem_info.h"
-
+#include "mem_info.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include "info.h"
-
+
class TMemInfoTest: public NUnitTest::TTestBase {
UNIT_TEST_SUITE(TMemInfoTest)
- UNIT_TEST(TestMemInfo)
+ UNIT_TEST(TestMemInfo)
UNIT_TEST_SUITE_END();
- void TestMemInfo() {
- using namespace NMemInfo;
-
- TMemInfo stats = GetMemInfo();
-
+ void TestMemInfo() {
+ using namespace NMemInfo;
+
+ TMemInfo stats = GetMemInfo();
+
UNIT_ASSERT(stats.RSS >= NSystemInfo::GetPageSize());
UNIT_ASSERT(stats.VMS >= stats.RSS);
- }
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TMemInfoTest)
+ }
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TMemInfoTest)
diff --git a/util/system/mutex.h b/util/system/mutex.h
index 6fac9a8f72..032630d134 100644
--- a/util/system/mutex.h
+++ b/util/system/mutex.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "guard.h"
#include "defaults.h"
diff --git a/util/system/pipe.h b/util/system/pipe.h
index 983d8a8b0d..75d0360049 100644
--- a/util/system/pipe.h
+++ b/util/system/pipe.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
diff --git a/util/system/platform.h b/util/system/platform.h
index 9b65a9247d..58f310ab34 100644
--- a/util/system/platform.h
+++ b/util/system/platform.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// ya style breaks indentation in ifdef's and code becomes unreadable
// clang-format off
diff --git a/util/system/progname.h b/util/system/progname.h
index f28ffa28c3..e5e2a0eee2 100644
--- a/util/system/progname.h
+++ b/util/system/progname.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
diff --git a/util/system/rwlock.h b/util/system/rwlock.h
index c10419a370..0bb9b3fe1c 100644
--- a/util/system/rwlock.h
+++ b/util/system/rwlock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "guard.h"
#include "defaults.h"
diff --git a/util/system/sem.h b/util/system/sem.h
index c777d17d7e..0c964ad6b6 100644
--- a/util/system/sem.h
+++ b/util/system/sem.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/sigset.h b/util/system/sigset.h
index f0bd42ae2e..8dd02fd817 100644
--- a/util/system/sigset.h
+++ b/util/system/sigset.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
// Functions for manipulating signal sets
diff --git a/util/system/spin_wait.h b/util/system/spin_wait.h
index e97d0df35c..91dd423e33 100644
--- a/util/system/spin_wait.h
+++ b/util/system/spin_wait.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
struct TSpinWait {
TSpinWait() noexcept;
diff --git a/util/system/spinlock.h b/util/system/spinlock.h
index 04beefdfca..af2630890a 100644
--- a/util/system/spinlock.h
+++ b/util/system/spinlock.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "atomic.h"
#include "spin_wait.h"
diff --git a/util/system/sys_alloc.h b/util/system/sys_alloc.h
index 29af4083e7..4221a28f8c 100644
--- a/util/system/sys_alloc.h
+++ b/util/system/sys_alloc.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/system/compiler.h>
diff --git a/util/system/tempfile.h b/util/system/tempfile.h
index ccb01bf5b0..de249c129d 100644
--- a/util/system/tempfile.h
+++ b/util/system/tempfile.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fs.h"
#include "file.h"
diff --git a/util/system/thread.h b/util/system/thread.h
index 7a0aa75cba..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
/// This code should not be used directly unless you really understand what you do.
/// If you need threads, use thread pool functionality in <util/thread/factory.h>
diff --git a/util/system/tls.h b/util/system/tls.h
index 358f9c8927..3c4f56dbeb 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
diff --git a/util/system/type_name.h b/util/system/type_name.h
index 7fc72d0f4a..b6619aba3f 100644
--- a/util/system/type_name.h
+++ b/util/system/type_name.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/string.h>
#include <util/string/subst.h>
diff --git a/util/system/valgrind.h b/util/system/valgrind.h
index ef01227aae..2ec4ed927c 100644
--- a/util/system/valgrind.h
+++ b/util/system/valgrind.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#if defined(WITH_VALGRIND) && defined(HAVE_VALGRIND)
#include <valgrind/valgrind.h>
diff --git a/util/system/yassert.h b/util/system/yassert.h
index 0dd4d8388e..529823440c 100644
--- a/util/system/yassert.h
+++ b/util/system/yassert.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "defaults.h"
#include "src_root.h"
diff --git a/util/system/yield.h b/util/system/yield.h
index 0ac6ba7d73..9965fb52b5 100644
--- a/util/system/yield.h
+++ b/util/system/yield.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
void SchedYield() noexcept;
void ThreadYield() noexcept;
diff --git a/util/thread/factory.h b/util/thread/factory.h
index 9ef3a6cfad..561fcbac88 100644
--- a/util/thread/factory.h
+++ b/util/thread/factory.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/ptr.h>
#include <functional>
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h
index db9da388be..ab523631e4 100644
--- a/util/thread/lfqueue.h
+++ b/util/thread/lfqueue.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h
index 9c410940f0..ca3d95f3c3 100644
--- a/util/thread/lfstack.h
+++ b/util/thread/lfstack.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/noncopyable.h>
#include <util/system/atomic.h>
diff --git a/util/thread/pool.h b/util/thread/pool.h
index 4543bab2f1..d1ea3a67cb 100644
--- a/util/thread/pool.h
+++ b/util/thread/pool.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include "fwd.h"
#include "factory.h"
diff --git a/util/ysafeptr.h b/util/ysafeptr.h
index d13c867b37..af7dfd4bed 100644
--- a/util/ysafeptr.h
+++ b/util/ysafeptr.h
@@ -1,5 +1,5 @@
-#pragma once
-
+#pragma once
+
#include <stddef.h>
#include <util/system/yassert.h>
#include <util/system/defaults.h>
diff --git a/util/ysaveload.h b/util/ysaveload.h
index ae6a59b0e7..02efb4049b 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include <util/generic/fwd.h>
#include <util/generic/strbuf.h>