summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-17 20:45:20 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-17 20:45:20 +0000
commitfde79b40c21dc397a2524c728f4102260eceafed (patch)
treef343a80dd2321803035224644d14f4d2051746df /clang/lib/Frontend/CompilerInvocation.cpp
parent01a3cf4d31f3e7fa5a8ab4b4b7622900acda5340 (diff)
downloadbcm5719-llvm-fde79b40c21dc397a2524c728f4102260eceafed.tar.gz
bcm5719-llvm-fde79b40c21dc397a2524c728f4102260eceafed.zip
unord: Extract key to avoid preemptive mallocs in insert/emplace
unordered_set::emplace and unordered_map::emplace construct a node, then try to insert it. If insertion fails, the node gets deleted. To avoid this unnecessary malloc traffic, check to see if the argument to emplace has the appropriate key_type. If so, we can use that key directly and delay the malloc until we're sure we're inserting something new. Test updates by Eric Fiselier, who rewrote the old allocation tests to include the new cases. There are two orthogonal future directions: 1. Apply the same optimization to set and map. 2. Extend the optimization to when the argument is not key_type, but can be converted to it without side effects. Ideally, we could do this whenever key_type is trivially destructible and the argument is trivially convertible to key_type, but in practise the relevant type traits "blow up sometimes". At least, we should catch a few simple cases (such as when both are primitive types). llvm-svn: 263746
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud