From c0873094f582f8dffda7eaea2ea21bd87f351570 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 19 Dec 2007 00:29:28 +0000 Subject: Use string length when available when calling Stringpool. Compare pointers first when looking up Stringpool entries. --- gold/stringpool.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gold/stringpool.h') 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& 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)) { } -- cgit v1.1