[llvm] r286232 - cleanup hashSysV a bit.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 06:04:16 PST 2016


Author: rafael
Date: Tue Nov  8 08:04:16 2016
New Revision: 286232

URL: http://llvm.org/viewvc/llvm-project?rev=286232&view=rev
Log:
cleanup hashSysV a bit.

Don't pass a reference to a StringRef and use a range loop.

Modified:
    llvm/trunk/include/llvm/Object/ELF.h

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=286232&r1=286231&r2=286232&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Tue Nov  8 08:04:16 2016
@@ -506,10 +506,10 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSec
 /// This function returns the hash value for a symbol in the .dynsym section
 /// Name of the API remains consistent as specified in the libelf
 /// REF : http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#hash
-static inline unsigned hashSysV(StringRef &symbolName) {
+inline unsigned hashSysV(StringRef SymbolName) {
   unsigned h = 0, g;
-  for (unsigned i = 0, j = symbolName.size(); i < j; i++) {
-    h = (h << 4) + symbolName[i];
+  for (char C : SymbolName) {
+    h = (h << 4) + C;
     g = h & 0xf0000000L;
     if (g != 0)
       h ^= g >> 24;




More information about the llvm-commits mailing list