From Craig Silverstein: Only sort for suffixes with -O2.
This commit is contained in:
parent
6119d2522e
commit
377caf49a5
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2007-09-21 00:18-0700\n"
|
||||
"POT-Creation-Date: 2007-09-21 08:52-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "output.h"
|
||||
#include "parameters.h"
|
||||
#include "stringpool.h"
|
||||
|
||||
namespace gold
|
||||
|
@ -303,6 +304,33 @@ Stringpool_template<Stringpool_char>::set_string_offsets()
|
|||
return;
|
||||
}
|
||||
|
||||
const size_t charsize = sizeof(Stringpool_char);
|
||||
|
||||
// Offset 0 may be reserved for the empty string.
|
||||
off_t offset = this->zero_null_ ? charsize : 0;
|
||||
|
||||
// Sorting to find suffixes can take over 25% of the total CPU time
|
||||
// used by the linker. Since it's merely an optimization to reduce
|
||||
// the strtab size, and gives a relatively small benefit (it's
|
||||
// typically rare for a symbol to be a suffix of another), we only
|
||||
// take the time to sort when the user asks for heavy optimization.
|
||||
if (parameters->optimization_level() < 2)
|
||||
{
|
||||
for (typename String_set_type::iterator curr = this->string_set_.begin();
|
||||
curr != this->string_set_.end();
|
||||
curr++)
|
||||
{
|
||||
if (this->zero_null_ && curr->first[0] == 0)
|
||||
curr->second.second = 0;
|
||||
else
|
||||
{
|
||||
curr->second.second = offset;
|
||||
offset += (string_length(curr->first) + 1) * charsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t count = this->string_set_.size();
|
||||
|
||||
std::vector<Stringpool_sort_info> v;
|
||||
|
@ -315,11 +343,6 @@ Stringpool_template<Stringpool_char>::set_string_offsets()
|
|||
|
||||
std::sort(v.begin(), v.end(), Stringpool_sort_comparison());
|
||||
|
||||
const size_t charsize = sizeof(Stringpool_char);
|
||||
|
||||
// Offset 0 may be reserved for the empty string.
|
||||
off_t offset = this->zero_null_ ? charsize : 0;
|
||||
|
||||
for (typename std::vector<Stringpool_sort_info>::iterator last = v.end(),
|
||||
curr = v.begin();
|
||||
curr != v.end();
|
||||
|
@ -340,6 +363,7 @@ Stringpool_template<Stringpool_char>::set_string_offsets()
|
|||
offset += (curr->string_length + 1) * charsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->strtab_size_ = offset;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue