X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gold%2Fstringpool.h;h=45ddbee86532eba8a53351dc619af7b437968000;hb=ca94519e70c39fca1d6ea93b8604349111522a8b;hp=f353c9d9a2f87e0ddfe0b37f3a67f9f49125a711;hpb=d099120c64430117a80fc95c0bff2da9ff5d8657;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/stringpool.h b/gold/stringpool.h index f353c9d9a2..45ddbee865 100644 --- a/gold/stringpool.h +++ b/gold/stringpool.h @@ -1,6 +1,6 @@ // stringpool.h -- a string pool for gold -*- C++ -*- -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. +// Copyright (C) 2006-2018 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -32,6 +32,28 @@ namespace gold class Output_file; +// Return the length of a string in units of Char_type. + +template +inline size_t +string_length(const Char_type* p) +{ + size_t len = 0; + for (; *p != 0; ++p) + ++len; + return len; +} + +// Specialize string_length for char. Maybe we could just use +// std::char_traits<>::length? + +template<> +inline size_t +string_length(const char* p) +{ + return strlen(p); +} + // A Stringpool is a pool of unique strings. It provides the // following features: @@ -96,7 +118,7 @@ class Chunked_vector { this->chunks_.resize((n + chunk_size - 1) / chunk_size); // We need to call reserve() of all chunks since changing - // this->chunks_ casues Element_vectors to be copied. The + // this->chunks_ causes Element_vectors to be copied. The // reserved capacity of an Element_vector may be lost in copying. for (size_t i = 0; i < this->chunks_.size(); ++i) this->chunks_[i].reserve(chunk_size); @@ -158,7 +180,7 @@ class Stringpool_template typedef size_t Key; // Create a Stringpool. - Stringpool_template(); + Stringpool_template(uint64_t addralign = 1); ~Stringpool_template(); @@ -197,6 +219,11 @@ class Stringpool_template const Stringpool_char* add(const Stringpool_char* s, bool copy, Key* pkey); + // Add the string S to the pool. + const Stringpool_char* + add(const std::basic_string& s, bool copy, Key* pkey) + { return this->add_with_length(s.data(), s.size(), copy, pkey); } + // Add string S of length LEN characters to the pool. If COPY is // true, S need not be null terminated. const Stringpool_char* @@ -266,10 +293,6 @@ class Stringpool_template Stringpool_template(const Stringpool_template&); Stringpool_template& operator=(const Stringpool_template&); - // Return the length of a string in units of Stringpool_char. - static size_t - string_length(const Stringpool_char*); - // Return whether two strings are equal. static bool string_equal(const Stringpool_char*, const Stringpool_char*); @@ -386,6 +409,8 @@ class Stringpool_template bool optimize_; // offset of the next string. section_offset_type offset_; + // The alignment of strings in the stringpool. + uint64_t addralign_; }; // The most common type of Stringpool.