forked from qt-creator/qt-creator
Utils: Don't allocate new memory if it is fitting in the short string
If you call reserve on a read only reference we always allocated on the heap which is not that smart. Change-Id: Ib9653c6fc87bc65716a966545c13f7ecb3712039 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -914,6 +914,15 @@ TEST(SmallString, ReserveSmallerThanShortStringCapacity)
|
||||
ASSERT_THAT(text.capacity(), AnyOf(30, 4));
|
||||
}
|
||||
|
||||
TEST(SmallString, ReserveSmallerThanShortStringCapacityIsShortString)
|
||||
{
|
||||
SmallString text("text");
|
||||
|
||||
text.reserve(2);
|
||||
|
||||
ASSERT_TRUE(text.isShortString());
|
||||
}
|
||||
|
||||
TEST(SmallString, ReserveSmallerThanReference)
|
||||
{
|
||||
SmallString text("some very very very very very very very very very very very long string");
|
||||
|
||||
Reference in New Issue
Block a user