aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringPool.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@nondot.org>2020-04-12 10:44:03 -0700
committerChris Lattner <clattner@nondot.org>2020-04-12 16:37:17 -0700
commit89c8ffd54221cfe2d0b5e391974143d08f047ae0 (patch)
treec5aadd9cba886259982b961a8c56675e5686d813 /llvm/lib/Support/StringPool.cpp
parentcfb844265aad44668029fce44ddc58adc81ad68a (diff)
downloadllvm-89c8ffd54221cfe2d0b5e391974143d08f047ae0.zip
llvm-89c8ffd54221cfe2d0b5e391974143d08f047ae0.tar.gz
llvm-89c8ffd54221cfe2d0b5e391974143d08f047ae0.tar.bz2
NFC: Clean up the implementation of StringPool a bit, and remove dependence on some "implicitly MallocAllocator" based methods on StringMapEntry. This allows reducing the #includes in StringMapEntry.h.
Summary: StringPool has many caveats and isn't used in the monorepo. I will propose removing it as a patch separate from this refactoring patch. Reviewers: rriddle Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77976
Diffstat (limited to 'llvm/lib/Support/StringPool.cpp')
-rw-r--r--llvm/lib/Support/StringPool.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/Support/StringPool.cpp b/llvm/lib/Support/StringPool.cpp
index 2746444..7d345df 100644
--- a/llvm/lib/Support/StringPool.cpp
+++ b/llvm/lib/Support/StringPool.cpp
@@ -1,4 +1,4 @@
-//===-- StringPool.cpp - Interned string pool -----------------------------===//
+//===-- StringPool.cpp - Intern'd string pool -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,25 +11,23 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/StringPool.h"
-#include "llvm/ADT/StringRef.h"
-#include <cassert>
-
using namespace llvm;
StringPool::StringPool() {}
StringPool::~StringPool() {
- assert(InternTable.empty() && "PooledStringPtr leaked!");
+ assert(internTable.empty() && "PooledStringPtr leaked!");
}
-PooledStringPtr StringPool::intern(StringRef Key) {
- table_t::iterator I = InternTable.find(Key);
- if (I != InternTable.end())
- return PooledStringPtr(&*I);
+PooledStringPtr StringPool::intern(StringRef key) {
+ auto it = internTable.find(key);
+ if (it != internTable.end())
+ return PooledStringPtr(&*it);
- entry_t *S = entry_t::Create(Key);
- S->getValue().Pool = this;
- InternTable.insert(S);
+ MallocAllocator allocator;
+ auto *entry = Entry::Create(key, allocator);
+ entry->getValue().pool = this;
+ internTable.insert(entry);
- return PooledStringPtr(S);
+ return PooledStringPtr(entry);
}