llvm-mc: Factor getSectionData out of SwitchSection.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 28 Aug 2009 05:48:54 +0000 (05:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 28 Aug 2009 05:48:54 +0000 (05:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCMachOStreamer.cpp

index e89f7d8dbd353f8e854c059fbd80465efaa34f7c..9f813fdc49e5bb13db3947dff3c3fc7bbe472466 100644 (file)
@@ -63,6 +63,15 @@ private:
     return 0;
   }
 
+  MCSectionData &getSectionData(const MCSection &Section) {
+    MCSectionData *&Entry = SectionMap[&Section];
+
+    if (!Entry)
+      Entry = new MCSectionData(Section, &Assembler);
+
+    return *Entry;
+  }
+
   MCSymbolData &getSymbolData(MCSymbol &Symbol) {
     MCSymbolData *&Entry = SymbolMap[&Symbol];
 
@@ -135,14 +144,9 @@ void MCMachOStreamer::SwitchSection(const MCSection *Section) {
   
   // If already in this section, then this is a noop.
   if (Section == CurSection) return;
-  
-  CurSection = Section;
-  MCSectionData *&Entry = SectionMap[Section];
 
-  if (!Entry)
-    Entry = new MCSectionData(*Section, &Assembler);
-
-  CurSectionData = Entry;
+  CurSection = Section;
+  CurSectionData = &getSectionData(*Section);
 }
 
 void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {