tra added inline comments.

================
Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:193
+  }
+  static unsigned getHashValue(const OffloadKind &Val) { return Val * 37U; }
+
----------------
jhuber6 wrote:
> tra wrote:
> > Is there a particular reason for multiplying by 37? Enum values by 
> > themselves should do the job just fine. 
> That's what LLVM does for the regular 
> `DenseMapInfo<uint16_t>::getHashValue()` so I just copied it here.
It would make sense for mapping the full range of uint16_t into a much smaller 
set of entries. In this case we're already dealing with a very small densely 
packed set of values. For all practical purposes is a convenient overkill We 
could get by with just using a vector+direct indexing. We also don't care about 
hash collisions even if they happen.

Removing multiplication would not make much of a difference, but it would be 
one less question for the reader to ask, when they look at this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123810

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to