[clang-tools-extra] r327901 - [clangd][nfc] Give name to a magic constant

Jan Korous via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 19 13:26:15 PDT 2018


Author: jkorous
Date: Mon Mar 19 13:26:15 2018
New Revision: 327901

URL: http://llvm.org/viewvc/llvm-project?rev=327901&view=rev
Log:
[clangd][nfc] Give name to a magic constant

Modified:
    clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327901&r1=327900&r2=327901&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:15 2018
@@ -56,16 +56,18 @@ public:
   }
 
 private:
+  static constexpr unsigned HashByteLength = 20;
+
   friend llvm::hash_code hash_value(const SymbolID &ID) {
     // We already have a good hash, just return the first bytes.
-    static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+    static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than SHA1!");
     return *reinterpret_cast<const size_t *>(ID.HashValue.data());
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
                                        const SymbolID &ID);
   friend void operator>>(llvm::StringRef Str, SymbolID &ID);
 
-  std::array<uint8_t, 20> HashValue;
+  std::array<uint8_t, HashByteLength> HashValue;
 };
 
 // Write SymbolID into the given stream. SymbolID is encoded as a 40-bytes




More information about the cfe-commits mailing list