diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-09-01 14:10:25 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-09-01 14:11:20 +0200 |
commit | 700433fc16e14292880ec9d329699e1cd889367e (patch) | |
tree | 56c8b525b8215f2aae4a84082d7d104405def7bd /src/shared/cplusplus | |
parent | b30ef6210bf9ba97e6e6f185ed20039b4a37710a (diff) | |
download | qt-creator-700433fc16e14292880ec9d329699e1cd889367e.tar.gz |
Tune the default size of literal tables.
This simple change will save about 40mb of memory when indexing Qt Creator!
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/LiteralTable.h | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/shared/cplusplus/LiteralTable.h b/src/shared/cplusplus/LiteralTable.h index 5a9a1f878b..80ada26e51 100644 --- a/src/shared/cplusplus/LiteralTable.h +++ b/src/shared/cplusplus/LiteralTable.h @@ -66,9 +66,9 @@ public: public: LiteralTable() : _literals(0), + _buckets(0), _allocatedLiterals(0), _literalCount(-1), - _buckets(0), _allocatedBuckets(0) { } @@ -127,17 +127,13 @@ public: _Literal *literal = new _Literal(chars, size); if (++_literalCount == _allocatedLiterals) { - _allocatedLiterals <<= 1; - - if (! _allocatedLiterals) - _allocatedLiterals = 256; - + _allocatedLiterals += 32; _literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals); } _literals[_literalCount] = literal; - if (! _buckets || _literalCount >= _allocatedBuckets * .6) + if (! _buckets || _literalCount * 5 >= _allocatedBuckets * 3) rehash(); else { unsigned h = literal->hashCode() % _allocatedBuckets; @@ -154,11 +150,7 @@ protected: if (_buckets) std::free(_buckets); - _allocatedBuckets <<= 1; - - if (! _allocatedBuckets) - _allocatedBuckets = 256; - + _allocatedBuckets += 32; _buckets = (_Literal **) std::calloc(_allocatedBuckets, sizeof(_Literal *)); _Literal **lastLiteral = _literals + (_literalCount + 1); @@ -174,10 +166,9 @@ protected: protected: _Literal **_literals; + _Literal **_buckets; int _allocatedLiterals; int _literalCount; - - _Literal **_buckets; int _allocatedBuckets; }; |