summaryrefslogtreecommitdiff
path: root/lib/Support/StringMap.cpp
AgeCommit message (Collapse)AuthorFilesLines
2012-08-29Add some __builtin_expect magic to StringMap.Benjamin Kramer1-4/+5
Tombstones and full hash collisions are rare, mark the "empty" and "no collision" paths as likely. The bug in simplifycfg that prevented the hints from being picked during selfhost up was fixed recently :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162874 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19Fix PR13148, an inf-loop in StringMap.Chandler Carruth1-1/+1
StringMap suffered from the same bug as DenseMap: when you explicitly construct it with a small number of buckets, you can arrange for the tombstone-based growth path to be followed when the number of buckets was less than '8'. In that case, even with a full map, it would compare '0' as not less than '0', and refuse to grow the table, leading to inf-loops trying to find an empty bucket on the next insertion. The fix is very simple: use '<=' as the comparison. The same fix was applied to DenseMap as well during its recent refactoring. Thanks to Alex Bolz for the great report and test case. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158725 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-27Switch StringMap from an array of structures to a structure of arrays.Benjamin Kramer1-27/+34
- -25% memory usage of the main table on x86_64 (was wasted in struct padding). - no significant performance change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147294 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-30Reset StringMap's NumTombstones on clears and rehashes.Jakob Stoklund Olesen1-0/+3
StringMap was not properly updating NumTombstones after a clear or rehash. This was not fatal until now because the table was growing faster than NumTombstones could, but with the previous change of preventing infinite growth of the table the invariant (NumItems + NumTombstones <= NumBuckets) stopped being observed, causing infinite loops in certain situations. Patch by José Fonseca! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128567 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-30Prevent infinite growth of SmallMap instances.Jakob Stoklund Olesen1-1/+13
Rehash but don't grow when full of tombstones. Patch by José Fonseca! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128565 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin1-1/+1
new gcc warning that complains on self-assignments and self-initializations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122458 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-06Pass StringRef by value.Daniel Dunbar1-3/+3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17Move StringMap's string has function into StringExtras.hDaniel Dunbar1-16/+3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84344 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-23Convert StringMap to using StringRef for its APIs.Daniel Dunbar1-16/+10
- Yay for '-'s and simplifications! - I kept StringMap::GetOrCreateValue for compatibility purposes, this can eventually go away. Likewise the StringMapEntry Create functions still follow the old style. - NIFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76888 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29Remove attribution from file headers, per discussion on llvmdev.Chris Lattner1-2/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04stringmap memory managed with malloc nowChris Lattner1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35666 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04use calloc instead of new/memset, it is more efficientChris Lattner1-4/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35644 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-04Extend StringMap to support being initialized as completely empty. WhenChris Lattner1-2/+22
initialized this way, they do not do a malloc to allocate their buckets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35642 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-03greatly reduce hte default size of stringmap.Chris Lattner1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35632 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11Add support for removing elements out of StringMap.Chris Lattner1-11/+52
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34185 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11Replace the ugly FindValue method with STL-like find methods.Chris Lattner1-0/+43
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34183 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11remove support for stringmap visitors now that iterators exist.Chris Lattner1-13/+0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34180 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-11add support for iterators.Chris Lattner1-2/+9
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34179 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08Rename CStringMap -> StringMap, since it now supports nul characters in theChris Lattner1-8/+8
strings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34064 91177308-0d34-0410-b5e6-96231b3b80d8
2007-02-08Allow cstringmap to contain strings with nul characters in them.Chris Lattner1-4/+5
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06wow, the link was already broken :)Chris Lattner1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32963 91177308-0d34-0410-b5e6-96231b3b80d8
2007-01-06add a noteChris Lattner1-1/+4
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32962 91177308-0d34-0410-b5e6-96231b3b80d8
2006-10-29add a highly efficient hash table that is specialized for mapping C stringsChris Lattner1-0/+134
to some other type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31286 91177308-0d34-0410-b5e6-96231b3b80d8