diff options
author | Howard Hinnant <hhinnant@apple.com> | 2012-08-03 18:01:20 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2012-08-03 18:01:20 +0000 |
commit | aca09de378ff4f5d87de2a75f14f9f9f650553c1 (patch) | |
tree | 084075c386aebec9481124d70f47817cfc9b52c6 /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | |
parent | 46342fecd039b8a9c7f14c60ff9896683a53bbf6 (diff) | |
download | bcm5719-llvm-aca09de378ff4f5d87de2a75f14f9f9f650553c1.tar.gz bcm5719-llvm-aca09de378ff4f5d87de2a75f14f9f9f650553c1.zip |
Performance tweaking rotate.
rotate is a critical algorithm because it is often used by other algorithms,
both std and non-std. The main thrust of this optimization is a specialized
algorithm when the 'distance' to be shifted is 1 (either left or right). To my
surprise, this 'optimization' was not effective for types like std::string.
std::string favors rotate algorithms which only use swap. But for types like
scalars, and especially when the sequence is random access, these new
specializations are a big win. If it is a vector<size_t> for example, the
rotate is done via a memmove and can be several times faster than the gcd
algorithm.
I'm using is_trivially_move_assignable to distinguish between types like int and
types like string. This is obviously an ad-hoc approximation, but I haven't
found a case where it doesn't give good results.
I've used a 'static if' (with is_trivially_move_assignable) in three places.
Testing with both -Os and -O3 showed that clang eliminated all code not be
executed by the 'static if' (including the 'static if' itself).
llvm-svn: 161247
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
0 files changed, 0 insertions, 0 deletions