diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-12 06:06:34 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-12 06:06:34 +0000 |
commit | cfd73a4e26b2ff2a1bee75cf425a9ecffe0ce6cd (patch) | |
tree | 7f01e893f545165f30c1dbd3f5680a0b4e4a54cf /gold/stringpool.cc | |
parent | 0ffd9845f2a947b9249296d3bc7a812bad1f7e07 (diff) | |
download | gdb-cfd73a4e26b2ff2a1bee75cf425a9ecffe0ce6cd.zip gdb-cfd73a4e26b2ff2a1bee75cf425a9ecffe0ce6cd.tar.gz gdb-cfd73a4e26b2ff2a1bee75cf425a9ecffe0ce6cd.tar.bz2 |
Add an option for Stringpools to not copy strings.
Diffstat (limited to 'gold/stringpool.cc')
-rw-r--r-- | gold/stringpool.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gold/stringpool.cc b/gold/stringpool.cc index d8b5211..bb571f0f 100644 --- a/gold/stringpool.cc +++ b/gold/stringpool.cc @@ -36,7 +36,7 @@ namespace gold template<typename Stringpool_char> Stringpool_template<Stringpool_char>::Stringpool_template() : string_set_(), strings_(), strtab_size_(0), next_index_(1), - zero_null_(true) + next_uncopied_key_(-1), zero_null_(true) { } @@ -205,7 +205,8 @@ Stringpool_template<Stringpool_char>::add_string(const Stringpool_char* s, template<typename Stringpool_char> const Stringpool_char* -Stringpool_template<Stringpool_char>::add(const Stringpool_char* s, Key* pkey) +Stringpool_template<Stringpool_char>::add(const Stringpool_char* s, bool copy, + Key* pkey) { // FIXME: This will look up the entry twice in the hash table. The // problem is that we can't insert S before we canonicalize it. I @@ -222,7 +223,15 @@ Stringpool_template<Stringpool_char>::add(const Stringpool_char* s, Key* pkey) } Key k; - const Stringpool_char* ret = this->add_string(s, &k); + const Stringpool_char* ret; + if (copy) + ret = this->add_string(s, &k); + else + { + ret = s; + k = this->next_uncopied_key_; + --this->next_uncopied_key_; + } const off_t ozero = 0; std::pair<const Stringpool_char*, Val> element(ret, @@ -241,13 +250,14 @@ Stringpool_template<Stringpool_char>::add(const Stringpool_char* s, Key* pkey) template<typename Stringpool_char> const Stringpool_char* -Stringpool_template<Stringpool_char>::add(const Stringpool_char* s, size_t len, - Key* pkey) +Stringpool_template<Stringpool_char>::add_prefix(const Stringpool_char* s, + size_t len, + Key* pkey) { // FIXME: This implementation should be rewritten when we rewrite // the hash table to avoid copying. std::basic_string<Stringpool_char> st(s, len); - return this->add(st, pkey); + return this->add(st.c_str(), true, pkey); } template<typename Stringpool_char> |