* configure.ac: Added gdb.modula2/Makefile to AC_OUTPUT.
[deliverable/binutils-gdb.git] / gold / stringpool.cc
index 43f63282db299f9d0e4207b1cac689d0d524dcb7..bb571f0fba2e90d80dd5b1ae76333d8018ab282b 100644 (file)
@@ -1,5 +1,25 @@
 // stringpool.cc -- a string pool for gold
 
+// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
 #include "gold.h"
 
 #include <cstring>
@@ -16,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)
 {
 }
 
@@ -91,7 +111,7 @@ Stringpool_template<Stringpool_char>::Stringpool_hash::operator()(
          const char* p = reinterpret_cast<const char*>(s);
          for (size_t i = 0; i < sizeof(Stringpool_char); ++i)
            {
-             result &= (size_t) *p++;
+             result ^= (size_t) *p++;
              result *= 1099511628211ULL;
            }
          ++s;
@@ -185,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
@@ -202,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,
@@ -221,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>
This page took 0.042517 seconds and 4 git commands to generate.