aboutsummaryrefslogtreecommitdiff
path: root/gold/stringpool.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-12-19 00:29:28 +0000
committerIan Lance Taylor <iant@google.com>2007-12-19 00:29:28 +0000
commitc0873094f582f8dffda7eaea2ea21bd87f351570 (patch)
treeb080a2190a75cc4a90bfaa40ab6b158636aa858b /gold/stringpool.h
parent2353d21439630f851ce2c38ed5f41973562c804a (diff)
downloadfsf-binutils-gdb-c0873094f582f8dffda7eaea2ea21bd87f351570.zip
fsf-binutils-gdb-c0873094f582f8dffda7eaea2ea21bd87f351570.tar.gz
fsf-binutils-gdb-c0873094f582f8dffda7eaea2ea21bd87f351570.tar.bz2
Use string length when available when calling Stringpool. Compare
pointers first when looking up Stringpool entries.
Diffstat (limited to 'gold/stringpool.h')
-rw-r--r--gold/stringpool.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/gold/stringpool.h b/gold/stringpool.h
index 0da7921..773bfc1 100644
--- a/gold/stringpool.h
+++ b/gold/stringpool.h
@@ -108,9 +108,10 @@ class Stringpool_template
const Stringpool_char*
add(const Stringpool_char* s, bool copy, Key* pkey);
- // Add the prefix of length LEN of string S to the pool.
+ // Add string S of length LEN characters to the pool. If COPY is
+ // true, S need not be null terminated.
const Stringpool_char*
- add_prefix(const Stringpool_char* s, size_t len, Key* pkey);
+ add_with_length(const Stringpool_char* s, size_t len, bool copy, Key* pkey);
// If the string S is present in the pool, return the canonical
// string pointer. Otherwise, return NULL. If PKEY is not NULL,
@@ -133,7 +134,12 @@ class Stringpool_template
// Get the offset of the string S in the string table.
section_offset_type
get_offset(const std::basic_string<Stringpool_char>& s) const
- { return this->get_offset(s.c_str()); }
+ { return this->get_offset_with_length(s.c_str(), s.size()); }
+
+ // Get the offset of string S, with length LENGTH characters, in the
+ // string table.
+ section_offset_type
+ get_offset_with_length(const Stringpool_char* s, size_t length) const;
// Get the size of the string table. This returns the number of
// bytes, not in units of Stringpool_char.
@@ -218,7 +224,7 @@ class Stringpool_template
// Note that these constructors are relatively expensive, because
// they compute the hash code.
- Hashkey(const Stringpool_char* s)
+ explicit Hashkey(const Stringpool_char* s)
: string(s), length(string_length(s)), hash_code(string_hash(s, length))
{ }