Browse Source

Restoring authorship annotation for <solar@yandex-team.ru>. Commit 2 of 2.

solar 3 years ago
parent
commit
2b7b1ea361

+ 7 - 7
library/cpp/bit_io/bitinput.h

@@ -1,11 +1,11 @@
-#pragma once 
- 
+#pragma once
+
 #include "bitinput_impl.h"
 
 #include <util/system/yassert.h>
 #include <util/generic/vector.h>
 #include <util/generic/yexception.h>
- 
+
 #include <iterator>
 
 namespace NBitIO {
@@ -119,7 +119,7 @@ namespace NBitIO {
         Y_FORCE_INLINE bool Read(ui64& result, ui64 bits) {
             return ReadImpl(result, bits);
         }
- 
+
         // Do not try to read more than 56 bits at once. Split in two reads or use ReadSafe.
         // Preserves what's in result.
         template <typename T>
@@ -136,7 +136,7 @@ namespace NBitIO {
         template <ui64 bits, typename T>
         Y_FORCE_INLINE bool ReadWords(T& result) {
             ui64 r64 = 0;
- 
+
             bool retCode = ReadWordsImpl<bits>(r64);
             result = r64;
 
@@ -152,11 +152,11 @@ namespace NBitIO {
         Y_FORCE_INLINE bool Back(int bits) {
             return Seek(BitOffset() - bits);
         }
- 
+
         Y_FORCE_INLINE bool Seek(int bitoffset) {
             return TBitInputImpl::Seek(bitoffset);
         }
- 
+
         // A way to read a portion of bits at random location.
         // Didn't want to complicate sequential read, neither to copypaste.
         template <typename T>

+ 4 - 4
library/cpp/bit_io/bitinput_impl.h

@@ -43,8 +43,8 @@ namespace NBitIO {
                 return false;
             }
             Start = FStart;
-            return true; 
-        } 
+            return true;
+        }
 
         Y_FORCE_INLINE bool ReadImpl(ui64& result, ui32 bits) {
             result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & MaskLowerBits(bits);
@@ -67,7 +67,7 @@ namespace NBitIO {
         Y_FORCE_INLINE ui64 BitOffset() const {
             return BOffset;
         }
- 
+
         Y_FORCE_INLINE bool Seek(i64 offset) {
             if (offset < 0 || offset > (i64)Length)
                 return false;
@@ -75,7 +75,7 @@ namespace NBitIO {
             Start = BOffset < FakeStart ? RealStart : FStart;
             return true;
         }
- 
+
     protected:
         template <ui64 bits, typename T>
         Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) {

+ 9 - 9
library/cpp/bit_io/bitoutput.h

@@ -1,5 +1,5 @@
-#pragma once 
- 
+#pragma once
+
 #include <library/cpp/deprecated/accessors/accessors.h>
 
 #include <util/stream/output.h>
@@ -7,7 +7,7 @@
 #include <util/generic/bitops.h>
 #include <util/generic/vector.h>
 #include <util/generic/yexception.h>
- 
+
 namespace NBitIO {
     // Based on junk/solar/codecs/bitstream.h
 
@@ -34,7 +34,7 @@ namespace NBitIO {
             , Offset()
         {
         }
- 
+
         ui64 GetOffset() const {
             return Offset + BytesUp(64ULL - FreeBits);
         }
@@ -49,13 +49,13 @@ namespace NBitIO {
 
     public:
         // interface
- 
+
         // Write "bits" lower bits.
         Y_FORCE_INLINE void Write(ui64 data, ui64 bits) {
             if (FreeBits < bits) {
                 if (FreeBits) {
                     bits -= FreeBits;
- 
+
                     Active |= (data & MaskLowerBits(FreeBits)) << (64ULL - FreeBits);
                     data >>= FreeBits;
 
@@ -67,8 +67,8 @@ namespace NBitIO {
 
             Active |= bits ? ((data & MaskLowerBits(bits)) << (64ULL - FreeBits)) : 0;
             FreeBits -= bits;
-        } 
- 
+        }
+
         // Write "bits" lower bits starting from "skipbits" bit.
         Y_FORCE_INLINE void Write(ui64 data, ui64 bits, ui64 skipbits) {
             Write(data >> skipbits, bits);
@@ -100,7 +100,7 @@ namespace NBitIO {
             }
 
             const ui64 padded = FreeBits & 7;
- 
+
             FreeBits = 64ULL;
             Active = 0ULL;
 

+ 16 - 16
library/cpp/codecs/huffman_codec.cpp

@@ -235,20 +235,20 @@ namespace NCodecs {
             THuffmanCache(const THuffmanCodec::TImpl& encoder);
 
             void Decode(NBitIO::TBitInput& in, TBuffer& out) const;
-        }; 
- 
+        };
+
         THolder<THuffmanCache> Cache;
- 
+
     public:
         TImpl()
             : SubTablesNum(1)
         {
             Invalid.CodeLength = 255;
         }
- 
+
         ui8 Encode(TStringBuf in, TBuffer& out) const {
             out.Clear();
- 
+
             if (in.empty()) {
                 return 0;
             }
@@ -302,8 +302,8 @@ namespace NCodecs {
                 } else {
                     while (ReadNextChar(bin, out)) {
                     }
-                } 
-            } 
+                }
+            }
         }
 
         Y_FORCE_INLINE int ReadNextChar(NBitIO::TBitInput& bin, TBuffer& out) const {
@@ -517,13 +517,13 @@ namespace NCodecs {
                     DecodeCache.push_back(*it);
                 }
                 totalBits += bits;
-            } 
-        } 
+            }
+        }
         DecodeCache.push_back(0);
         CacheEntries.shrink_to_fit();
         DecodeCache.shrink_to_fit();
-    } 
- 
+    }
+
     void THuffmanCodec::TImpl::THuffmanCache::Decode(NBitIO::TBitInput& bin, TBuffer& out) const {
         int bits = 0;
         ui64 code = 0;
@@ -541,13 +541,13 @@ namespace NCodecs {
                 bin.Back(bits);
                 if (!Original.ReadNextChar(bin, out))
                     break;
- 
+
                 code = 0;
                 bits = 0;
             }
-        } 
-    } 
- 
+        }
+    }
+
     THuffmanCodec::THuffmanCodec()
         : Impl(new TImpl)
     {
@@ -588,5 +588,5 @@ namespace NCodecs {
         Impl->LearnByFreqs(freqs);
         Trained = true;
     }
- 
+
 }

+ 11 - 11
util/draft/date.cpp

@@ -15,17 +15,17 @@ time_t GetDateStart(time_t ts) {
     dateTm.tm_min = 0;
     dateTm.tm_hour = 0;
     return mktime(&dateTm);
-} 
- 
+}
+
 static time_t ParseDate(const char* date, const char* format) {
-    tm dateTm; 
-    memset(&dateTm, 0, sizeof(tm)); 
+    tm dateTm;
+    memset(&dateTm, 0, sizeof(tm));
     if (!strptime(date, format, &dateTm)) {
         ythrow yexception() << "Invalid date string and format: " << date << ", " << format;
     }
     return mktime(&dateTm);
-} 
- 
+}
+
 static time_t ParseDate(const char* dateStr) {
     if (strlen(dateStr) != 8) {
         ythrow yexception() << "Invalid date string: " << dateStr;
@@ -51,9 +51,9 @@ TDate::TDate(const TString& yyyymmdd)
 
 TDate::TDate(time_t ts)
     : Timestamp(GetDateStart(ts))
-{ 
-} 
- 
+{
+}
+
 TDate::TDate(const TString& date, const TString& format)
     : Timestamp(GetDateStart(ParseDate(date.data(), format.data())))
 {
@@ -86,8 +86,8 @@ TString TDate::ToStroka(const char* format) const {
     tm dateTm;
     localtime_r(&Timestamp, &dateTm);
     return Strftime(format, &dateTm);
-} 
- 
+}
+
 unsigned TDate::GetWeekDay() const {
     tm dateTm;
     localtime_r(&Timestamp, &dateTm);

+ 44 - 44
util/draft/date.h

@@ -1,10 +1,10 @@
 #pragma once
- 
+
 #include <util/stream/output.h>
 #include <util/stream/input.h>
 #include <util/generic/string.h>
 #include <util/datetime/constants.h>
- 
+
 #include <ctime>
 
 // XXX: uses system calls for trivial things. may be very slow therefore.
@@ -12,46 +12,46 @@
 time_t GetDateStart(time_t ts);
 
 // Local date (without time zone)
-class TDate { 
+class TDate {
     // XXX: wrong: must store number of days since epoch
-    time_t Timestamp; 
- 
-public: 
-    TDate() 
-        : Timestamp(0) 
-    { 
-    } 
- 
+    time_t Timestamp;
+
+public:
+    TDate()
+        : Timestamp(0)
+    {
+    }
+
     // XXX: wrong. Should be replace with two methods: TodayGmt() and TodayLocal()
     static TDate Today() {
         return TDate(time(nullptr));
-    } 
- 
+    }
+
     TDate(const char* yyyymmdd);
     TDate(const TString& yyyymmdd);
     TDate(unsigned year, unsigned month, unsigned monthDay); // month from 01, monthDay from 01
     TDate(const TString& date, const TString& format);
 
     explicit TDate(time_t t);
- 
+
     time_t GetStart() const {
-        return Timestamp; 
-    } 
- 
+        return Timestamp;
+    }
+
     time_t GetStartUTC() const;
 
     TString ToStroka(const char* format = "%Y%m%d") const;
- 
+
     TDate& operator++() {
         Timestamp = GetDateStart(Timestamp + 3 * (SECONDS_IN_DAY / 2));
-        return *this; 
-    } 
- 
+        return *this;
+    }
+
     TDate& operator--() {
         Timestamp = GetDateStart(Timestamp - SECONDS_IN_DAY / 2);
-        return *this; 
-    } 
- 
+        return *this;
+    }
+
     TDate& operator+=(unsigned days) {
         Timestamp = GetDateStart(Timestamp + days * SECONDS_IN_DAY + SECONDS_IN_DAY / 2);
         return *this;
@@ -82,33 +82,33 @@ public:
     friend bool operator>=(const TDate& left, const TDate& right);
     friend bool operator==(const TDate& left, const TDate& right);
     friend int operator-(const TDate& left, const TDate& right);
- 
+
     friend IInputStream& operator>>(IInputStream& left, TDate& right);
     friend IOutputStream& operator<<(IOutputStream& left, const TDate& right);
-}; 
- 
+};
+
 Y_DECLARE_PODTYPE(TDate);
 
 inline bool operator<(const TDate& left, const TDate& right) {
-    return left.Timestamp < right.Timestamp; 
-} 
- 
+    return left.Timestamp < right.Timestamp;
+}
+
 inline bool operator>(const TDate& left, const TDate& right) {
-    return left.Timestamp > right.Timestamp; 
-} 
- 
+    return left.Timestamp > right.Timestamp;
+}
+
 inline bool operator<=(const TDate& left, const TDate& right) {
-    return left.Timestamp <= right.Timestamp; 
-} 
- 
+    return left.Timestamp <= right.Timestamp;
+}
+
 inline bool operator>=(const TDate& left, const TDate& right) {
-    return left.Timestamp >= right.Timestamp; 
-} 
- 
+    return left.Timestamp >= right.Timestamp;
+}
+
 inline bool operator==(const TDate& left, const TDate& right) {
-    return left.Timestamp == right.Timestamp; 
-} 
- 
+    return left.Timestamp == right.Timestamp;
+}
+
 inline int operator-(const TDate& left, const TDate& right) {
     if (left < right) {
         return -(right - left);
@@ -125,5 +125,5 @@ inline IInputStream& operator>>(IInputStream& left, TDate& right) {
 }
 
 inline IOutputStream& operator<<(IOutputStream& left, const TDate& right) {
-    return left << right.ToStroka(); 
-} 
+    return left << right.ToStroka();
+}