diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-08 17:07:47 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2007-12-08 17:07:47 +0000 |
commit | 4b41a6f5290bcae21102a5c4771376538d81a054 (patch) | |
tree | 805d5d80db6bcb0e09d4d528b32991fa3b46193c /llvm/lib/Support/StringPool.cpp | |
parent | 05481d91be8267641fdc93ee7cca8ffbed102111 (diff) | |
download | bcm5719-llvm-4b41a6f5290bcae21102a5c4771376538d81a054.tar.gz bcm5719-llvm-4b41a6f5290bcae21102a5c4771376538d81a054.zip |
Adding a StringPool data structure, which GC will use.
llvm-svn: 44705
Diffstat (limited to 'llvm/lib/Support/StringPool.cpp')
-rw-r--r-- | llvm/lib/Support/StringPool.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Support/StringPool.cpp b/llvm/lib/Support/StringPool.cpp new file mode 100644 index 00000000000..6b34d2c4a01 --- /dev/null +++ b/llvm/lib/Support/StringPool.cpp @@ -0,0 +1,35 @@ +//===-- StringPool.cpp - Interned string pool -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Gordon Henriksen and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the StringPool class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/StringPool.h" +#include "llvm/Support/Streams.h" + +using namespace llvm; + +StringPool::StringPool() {} + +StringPool::~StringPool() { + assert(InternTable.empty() && "PooledStringPtr leaked!"); +} + +PooledStringPtr StringPool::intern(const char *Begin, const char *End) { + table_t::iterator I = InternTable.find(Begin, End); + if (I != InternTable.end()) + return PooledStringPtr(&*I); + + entry_t *S = entry_t::Create(Begin, End); + S->getValue().Pool = this; + InternTable.insert(S); + + return PooledStringPtr(S); +} |