From c2dca5d76e024886b15b002fdf131ae1f9aac7a5 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 11 Feb 2016 01:07:18 +0000 Subject: [PATCH] Reduce code repetition. NFC. llvm-svn: 260476 --- lld/ELF/Writer.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3cddbf5..aa4bd43 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -725,20 +725,10 @@ StringRef Writer::getOutputSectionName(StringRef S) const { 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; } -- 2.7.4