Utils: Simplify SmallString reserve

The reserve function is quite complicated because it is implementing a
grow pattern. Something we seldom need. So we now align to the next cache
line size.

Change-Id: I14bb88c12bd740a7afa7cd08969a4e07fb0f9add
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-09-14 11:48:17 +02:00
parent e255baaa8f
commit 76a7dff82b
2 changed files with 6 additions and 15 deletions

View File

@@ -658,18 +658,9 @@ unittest_public:
{
const size_type cacheLineSize = 64;
const auto divisionByCacheLineSize = std::div(int64_t(size), int64_t(cacheLineSize));
size_type cacheLineBlocks = (size - 1) / cacheLineSize;
size_type cacheLineBlocks = size_type(divisionByCacheLineSize.quot);
const size_type supplement = divisionByCacheLineSize.rem ? 1 : 0;
cacheLineBlocks += supplement;
int exponent;
const double significand = std::frexp(cacheLineBlocks, &exponent);
const double factorOneDotFiveSignificant = std::ceil(significand * 4.) / 4.;
cacheLineBlocks = size_type(std::ldexp(factorOneDotFiveSignificant, exponent));
return cacheLineBlocks * cacheLineSize;
return (cacheLineBlocks + 1) * cacheLineSize;
}
size_type countOccurrence(SmallStringView text)