diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-05-18 12:15:34 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-05-18 12:15:34 +0000 |
commit | 47f9a49560cbf629ff36f3efb591d70b29471320 (patch) | |
tree | beda81d196d4bb16dc014d103522b9ae408da22a | |
parent | 853197557c7cad1c503b216ab51db44e05609fab (diff) |
Simplify MCContext::(Next|Get)Instance
- Allocate MCLabels in the context so they don't leak.
- Avoid duplicated densemap lookup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104020 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/MCContext.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 5cc72e8e9f..53ffc9409a 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -73,33 +73,17 @@ MCSymbol *MCContext::CreateTempSymbol() { } unsigned MCContext::NextInstance(int64_t LocalLabelVal) { - unsigned Instance; - MCLabel *Label; - Label = Instances[LocalLabelVal]; - if (Label) { - Instance = Label->incInstance(); - } - else { - Instance = 1; - Label = new MCLabel(Instance); - Instances[LocalLabelVal] = Label; - } - return Instance; + MCLabel *&Label = Instances[LocalLabelVal]; + if (!Label) + Label = new (*this) MCLabel(0); + return Label->incInstance(); } unsigned MCContext::GetInstance(int64_t LocalLabelVal) { - int Instance; - MCLabel *Label; - Label = Instances[LocalLabelVal]; - if (Label) { - Instance = Label->getInstance(); - } - else { - Instance = 0; - Label = new MCLabel(Instance); - Instances[LocalLabelVal] = Label; - } - return Instance; + MCLabel *&Label = Instances[LocalLabelVal]; + if (!Label) + Label = new (*this) MCLabel(0); + return Label->getInstance(); } MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) { |