From: Benjamin Kramer Date: Mon, 23 Aug 2010 21:23:52 +0000 (+0000) Subject: Reduce code duplication. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=36c6dc22bcaed92f03f7019a0d1cd47ea69e12da;p=oota-llvm.git Reduce code duplication. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111846 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index c70f93cd14d..79b89ba0b6e 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -64,8 +64,8 @@ namespace { // Support lexicographic sorting. bool operator<(const ELFSymbolData &RHS) const { - const std::string &Name = SymbolData->getSymbol().getName(); - return Name < RHS.SymbolData->getSymbol().getName(); + return SymbolData->getSymbol().getName() < + RHS.SymbolData->getSymbol().getName(); } }; @@ -151,21 +151,13 @@ namespace { } void StringLE32(char *buf, uint32_t Value) { - buf[0] = char(Value >> 0); - buf[1] = char(Value >> 8); - buf[2] = char(Value >> 16); - buf[3] = char(Value >> 24); + StringLE16(buf, uint16_t(Value >> 0)); + StringLE16(buf, uint16_t(Value >> 16)); } void StringLE64(char *buf, uint64_t Value) { - buf[0] = char(Value >> 0); - buf[1] = char(Value >> 8); - buf[2] = char(Value >> 16); - buf[3] = char(Value >> 24); - buf[4] = char(Value >> 32); - buf[5] = char(Value >> 40); - buf[6] = char(Value >> 48); - buf[7] = char(Value >> 56); + StringLE32(buf, uint32_t(Value >> 0)); + StringLE32(buf, uint32_t(Value >> 32)); } void StringBE16(char *buf ,uint16_t Value) { @@ -174,21 +166,13 @@ namespace { } void StringBE32(char *buf, uint32_t Value) { - buf[0] = char(Value >> 24); - buf[1] = char(Value >> 16); - buf[2] = char(Value >> 8); - buf[3] = char(Value >> 0); + StringBE16(buf, uint16_t(Value >> 16)); + StringBE16(buf, uint16_t(Value >> 0)); } void StringBE64(char *buf, uint64_t Value) { - buf[0] = char(Value >> 56); - buf[1] = char(Value >> 48); - buf[2] = char(Value >> 40); - buf[3] = char(Value >> 32); - buf[4] = char(Value >> 24); - buf[5] = char(Value >> 16); - buf[6] = char(Value >> 8); - buf[7] = char(Value >> 0); + StringBE32(buf, uint32_t(Value >> 32)); + StringBE32(buf, uint32_t(Value >> 0)); } void String16(char *buf, uint16_t Value) {