Browse Source

Restoring authorship annotation for Michael Roizner <mroizner@gmail.com>. Commit 2 of 2.

Michael Roizner 3 years ago
parent
commit
4e10711f67

+ 24 - 24
library/cpp/yt/misc/property.h

@@ -1,7 +1,7 @@
-#pragma once 
- 
-//////////////////////////////////////////////////////////////////////////////// 
- 
+#pragma once
+
+////////////////////////////////////////////////////////////////////////////////
+
 //! Declares a trivial public read-write property that is passed by reference.
 #define DECLARE_BYREF_RW_PROPERTY(type, name) \
 public: \
@@ -13,18 +13,18 @@ public: \
 #define DEFINE_BYREF_RW_PROPERTY(type, name, ...) \
 protected: \
     type name##_ { __VA_ARGS__ }; \
-    \ 
-public: \ 
+    \
+public: \
     Y_FORCE_INLINE type& name() \
-    { \ 
-        return name##_; \ 
-    } \ 
-    \ 
+    { \
+        return name##_; \
+    } \
+    \
     Y_FORCE_INLINE const type& name() const \
-    { \ 
-        return name##_; \ 
-    } 
- 
+    { \
+        return name##_; \
+    }
+
 //! Defines a trivial public read-write property that is passed by reference
 //! and is not inline-initialized.
 #define DEFINE_BYREF_RW_PROPERTY_NO_INIT(type, name) \
@@ -105,18 +105,18 @@ public: \
 #define DEFINE_BYVAL_RW_PROPERTY(type, name, ...) \
 protected: \
     type name##_ { __VA_ARGS__ }; \
-    \ 
-public: \ 
+    \
+public: \
     Y_FORCE_INLINE type Get##name() const \
-    { \ 
-        return name##_; \ 
-    } \ 
-    \ 
+    { \
+        return name##_; \
+    } \
+    \
     Y_FORCE_INLINE void Set##name(type value) \
-    { \ 
-        name##_ = value; \ 
+    { \
+        name##_ = value; \
     } \
- 
+
 //! Defines a trivial public read-write property that is passed by value.
 //! All arguments after name are used as default value (via braced-init-list).
 #define DEFINE_BYVAL_RW_PROPERTY_WITH_FLUENT_SETTER(declaringType, type, name, ...) \
@@ -208,7 +208,7 @@ public: \
         return (delegateTo).Get##name(); \
     }
 
-//////////////////////////////////////////////////////////////////////////////// 
+////////////////////////////////////////////////////////////////////////////////
 
 //! Below are macro helpers for extra properties.
 //! Extra properties should be used for lazy memory allocation for properties that

+ 1 - 1
library/cpp/yt/string/enum.h

@@ -13,7 +13,7 @@ namespace NYT {
 TString DecodeEnumValue(TStringBuf value);
 TString EncodeEnumValue(TStringBuf value);
 
-template <class T> 
+template <class T>
 T ParseEnum(TStringBuf value);
 
 template <class T>

+ 26 - 26
util/system/file.cpp

@@ -339,25 +339,25 @@ bool TFileHandle::Resize(i64 length) noexcept {
     if (!IsOpen()) {
         return false;
     }
-    i64 currentLength = GetLength(); 
+    i64 currentLength = GetLength();
     if (length == currentLength) {
-        return true; 
+        return true;
     }
 #if defined(_win_)
-    i64 currentPosition = GetPosition(); 
+    i64 currentPosition = GetPosition();
     if (currentPosition == -1L) {
         return false;
     }
-    Seek(length, sSet); 
+    Seek(length, sSet);
     if (!::SetEndOfFile(Fd_)) {
         return false;
     }
     if (currentPosition < length) {
-        Seek(currentPosition, sSet); 
+        Seek(currentPosition, sSet);
     }
     return true;
 #elif defined(_unix_)
-    return (0 == ftruncate(Fd_, (off_t)length)); 
+    return (0 == ftruncate(Fd_, (off_t)length));
 #else
     #error unsupported platform
 #endif
@@ -366,28 +366,28 @@ bool TFileHandle::Resize(i64 length) noexcept {
 bool TFileHandle::Reserve(i64 length) noexcept {
     // FIXME this should reserve disk space with fallocate
     if (!IsOpen()) {
-        return false; 
+        return false;
     }
-    i64 currentLength = GetLength(); 
+    i64 currentLength = GetLength();
     if (length <= currentLength) {
-        return true; 
+        return true;
     }
     if (!Resize(length)) {
-        return false; 
+        return false;
     }
 #if defined(_win_)
-    if (!::SetFileValidData(Fd_, length)) { 
-        Resize(currentLength); 
-        return false; 
-    } 
+    if (!::SetFileValidData(Fd_, length)) {
+        Resize(currentLength);
+        return false;
+    }
 #elif defined(_unix_)
 // No way to implement this under FreeBSD. Just do nothing
-#else 
+#else
     #error unsupported platform
-#endif 
-    return true; 
-} 
- 
+#endif
+    return true;
+}
+
 bool TFileHandle::FallocateNoResize(i64 length) noexcept {
     if (!IsOpen()) {
         return false;
@@ -897,7 +897,7 @@ public:
             ythrow TFileError() << "can't reserve " << length << " for file " << FileName_.Quote();
         }
     }
- 
+
     void FallocateNoResize(i64 length) {
         if (!Handle_.FallocateNoResize(length)) {
             ythrow TFileError() << "can't allocate " << length << "bytes of space for file " << FileName_.Quote();
@@ -1137,14 +1137,14 @@ i64 TFile::Seek(i64 offset, SeekDir origin) {
     return Impl_->Seek(offset, origin);
 }
 
-void TFile::Resize(i64 length) { 
-    Impl_->Resize(length); 
+void TFile::Resize(i64 length) {
+    Impl_->Resize(length);
+}
+
+void TFile::Reserve(i64 length) {
+    Impl_->Reserve(length);
 }
 
-void TFile::Reserve(i64 length) { 
-    Impl_->Reserve(length); 
-} 
- 
 void TFile::FallocateNoResize(i64 length) {
     Impl_->FallocateNoResize(length);
 }

+ 2 - 2
util/system/file.h

@@ -162,8 +162,8 @@ public:
     FHANDLE GetHandle() const noexcept;
 
     i64 Seek(i64 offset, SeekDir origin);
-    void Resize(i64 length); 
-    void Reserve(i64 length); 
+    void Resize(i64 length);
+    void Reserve(i64 length);
     void FallocateNoResize(i64 length);
     void ShrinkToFit();
     void Flush();

+ 6 - 6
util/system/file_ut.cpp

@@ -92,24 +92,24 @@ public:
 
         UNIT_ASSERT_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "67895678");
     }
- 
+
     inline void TestResize() {
         TTempFile tmp("tmp");
- 
+
         {
             TFile file(tmp.Name(), OpenAlways | WrOnly);
- 
+
             file.Write("1234567", 7);
             file.Seek(3, sSet);
- 
+
             file.Resize(5);
             UNIT_ASSERT_EQUAL(file.GetLength(), 5);
             UNIT_ASSERT_EQUAL(file.GetPosition(), 3);
- 
+
             file.Resize(12);
             UNIT_ASSERT_EQUAL(file.GetLength(), 12);
             UNIT_ASSERT_EQUAL(file.GetPosition(), 3);
-        } 
+        }
 
         const TString data = TUnbufferedFileInput(tmp.Name()).ReadAll();
         UNIT_ASSERT_EQUAL(data.length(), 12);

+ 6 - 6
util/system/filemap.cpp

@@ -474,20 +474,20 @@ TFileMap::TFileMap(const TFileMap& fm) noexcept
 {
 }
 
-void TFileMap::Flush(void* ptr, size_t size, bool sync) { 
+void TFileMap::Flush(void* ptr, size_t size, bool sync) {
     Y_ASSERT(ptr >= Ptr());
     Y_ASSERT(static_cast<char*>(ptr) + size <= static_cast<char*>(Ptr()) + MappedSize());
- 
+
     if (!Region_.IsMapped()) {
         return;
     }
 
 #if defined(_win_)
-    if (sync) { 
-        FlushViewOfFile(ptr, size); 
-    } 
+    if (sync) {
+        FlushViewOfFile(ptr, size);
+    }
 #else
-    msync(ptr, size, sync ? MS_SYNC : MS_ASYNC); 
+    msync(ptr, size, sync ? MS_SYNC : MS_ASYNC);
 #endif
 }
 

+ 4 - 4
util/system/filemap.h

@@ -129,15 +129,15 @@ public:
     void Flush() {
         Flush(Ptr(), MappedSize());
     }
- 
+
     void FlushAsync(void* ptr, size_t size) {
         Flush(ptr, size, false);
     }
- 
+
     void FlushAsync() {
         FlushAsync(Ptr(), MappedSize());
     }
- 
+
     inline i64 Length() const noexcept {
         return Map_.Length();
     }
@@ -178,7 +178,7 @@ public:
 
 private:
     void Flush(void* ptr, size_t size, bool sync);
- 
+
     TMemoryMap Map_;
     TMapResult Region_;
 };