crlib: reduce hashmap memory usage.
build: fixed clang build.
This commit is contained in:
parent
17b9200195
commit
d40aab2b40
3 changed files with 14 additions and 7 deletions
|
|
@ -103,8 +103,15 @@ private:
|
||||||
return hash_ (key) % length;
|
return hash_ (key) % length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rehash () {
|
void rehash (size_t targetCapacity) {
|
||||||
auto capacity = (capacity_ << 1);
|
if (length_ + targetCapacity < capacity_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto capacity = capacity_ ? capacity_ : 3;
|
||||||
|
|
||||||
|
while (length_ + targetCapacity > capacity) {
|
||||||
|
capacity *= 2;
|
||||||
|
}
|
||||||
auto contents = cr::makeUnique <Entries> (capacity);
|
auto contents = cr::makeUnique <Entries> (capacity);
|
||||||
|
|
||||||
for (size_t i = 0; i < capacity_; ++i) {
|
for (size_t i = 0; i < capacity_; ++i) {
|
||||||
|
|
@ -188,7 +195,7 @@ public:
|
||||||
for (size_t i = 0; i < capacity_; ++i) {
|
for (size_t i = 0; i < capacity_; ++i) {
|
||||||
contents_[i].used = false;
|
contents_[i].used = false;
|
||||||
}
|
}
|
||||||
rehash ();
|
rehash (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void foreach (Lambda <void (const K &, const V &)> callback) {
|
void foreach (Lambda <void (const K &, const V &)> callback) {
|
||||||
|
|
@ -201,8 +208,8 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
V &operator [] (const K &key) {
|
V &operator [] (const K &key) {
|
||||||
if ((length_ << 1) > capacity_) {
|
if (length_ >= capacity_) {
|
||||||
rehash ();
|
rehash (length_ << 1);
|
||||||
}
|
}
|
||||||
auto result = put (key, contents_, capacity_);
|
auto result = put (key, contents_, capacity_);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ private:
|
||||||
StringArray m_logos;
|
StringArray m_logos;
|
||||||
StringArray m_avatars;
|
StringArray m_avatars;
|
||||||
|
|
||||||
HashMap <uint32, String, Hash <int32>> m_language { 256 };
|
HashMap <uint32, String, Hash <int32>> m_language;
|
||||||
HashMap <int32, DifficultyData> m_difficulty;
|
HashMap <int32, DifficultyData> m_difficulty;
|
||||||
|
|
||||||
// default tables for personality weapon preferences, overridden by weapon.cfg
|
// default tables for personality weapon preferences, overridden by weapon.cfg
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,11 @@ if isCLang or isGCC or (isIntel and not isWindows)
|
||||||
|
|
||||||
if isGCC
|
if isGCC
|
||||||
flagsCompiler += '-fgraphite-identity'
|
flagsCompiler += '-fgraphite-identity'
|
||||||
|
flagsLinker += '-flto-partition=none'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
flagsLinker += [
|
flagsLinker += [
|
||||||
'-flto',
|
'-flto',
|
||||||
'-flto-partition=none',
|
|
||||||
'-s',
|
'-s',
|
||||||
'-Wl,--version-script=../version_script.lds',
|
'-Wl,--version-script=../version_script.lds',
|
||||||
'-Wl,--gc-sections'
|
'-Wl,--gc-sections'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue