[PATCH] D59816: [Support] Implement zlib independent crc32 computation

Joerg Sonnenberger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 06:42:30 PDT 2019


joerg added inline comments.


================
Comment at: lib/Support/CRC.cpp:21
+// Implementation was taken from libarchive:
+// github.com/libarchive/libarchive/blob/master/libarchive/archive_crc32.h
+uint32_t llvm::getCRC32(uint32_t CRC, StringRef S) {
----------------
A reference in the commit message is good enough.


================
Comment at: lib/Support/CRC.cpp:23
+uint32_t llvm::getCRC32(uint32_t CRC, StringRef S) {
+  static std::atomic<bool> CRCTblInited(false);
+  static uint32_t CRCTable[256];
----------------
You can just use llvm::call_once for the init.


================
Comment at: lib/Support/CRC.cpp:27
+  auto Shuffle = [](uint32_t V) {
+    return (V & 1) ? (V >> 1) ^ 0xEDB88320 : V >> 1;
+  };
----------------
I'd prefer to add the U for the constant here and below as they don't fit into the normal integer range.


================
Comment at: lib/Support/CRC.cpp:44
+
+  const char *P = S.data();
+  size_t Len = S.size();
----------------
uint8_t or at least unsigned char would still be better here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59816/new/

https://reviews.llvm.org/D59816





More information about the llvm-commits mailing list