Utils: Improve SmallString

The small string control block moved to the beginning, so it is more cache
local. The control block is cleanup too, so it should be easier to read.
The alignment is removed because it is creating to big holes.

Change-Id: I401aeb9d55455cbaa5e722dd8192e54b525ddc40
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-03-26 17:10:17 +02:00
parent 0ecd543614
commit b6cb22899c
6 changed files with 167 additions and 95 deletions

View File

@@ -51,6 +51,7 @@ struct SmallStringIterator : public std::iterator<Category, Type, DistanceType,
{
return ++pointer_;
}
SmallStringIterator operator++(int) noexcept
{
return pointer_++;
@@ -121,16 +122,19 @@ struct SmallStringIterator : public std::iterator<Category, Type, DistanceType,
return pointer_;
}
constexpr
bool operator==(SmallStringIterator other) const noexcept
{
return pointer_ == other.pointer_;
}
constexpr
bool operator!=(SmallStringIterator other) const noexcept
{
return pointer_ != other.pointer_;
}
constexpr
bool operator<(SmallStringIterator other) const noexcept
{
return pointer_ < other.pointer_;
@@ -141,6 +145,11 @@ struct SmallStringIterator : public std::iterator<Category, Type, DistanceType,
return pointer_;
}
const Pointer data() const noexcept
{
return pointer_;
}
private:
Pointer pointer_ = nullptr;
};