[lld] r260476 - Reduce code repetition. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 17:07:18 PST 2016


Author: ruiu
Date: Wed Feb 10 19:07:18 2016
New Revision: 260476

URL: http://llvm.org/viewvc/llvm-project?rev=260476&view=rev
Log:
Reduce code repetition. NFC.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=260476&r1=260475&r2=260476&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Feb 10 19:07:18 2016
@@ -725,20 +725,10 @@ StringRef Writer<ELFT>::getOutputSection
   if (It != std::end(InputToOutputSection))
     return It->second;
 
-  if (S.startswith(".text."))
-    return ".text";
-  if (S.startswith(".rodata."))
-    return ".rodata";
-  if (S.startswith(".data.rel.ro"))
-    return ".data.rel.ro";
-  if (S.startswith(".data."))
-    return ".data";
-  if (S.startswith(".bss."))
-    return ".bss";
-  if (S.startswith(".init_array."))
-    return ".init_array";
-  if (S.startswith(".fini_array."))
-    return ".fini_array";
+  for (StringRef V : {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.",
+                      ".init_array.", ".fini_array."})
+    if (S.startswith(V))
+      return V.drop_back();
   return S;
 }
 




More information about the llvm-commits mailing list