Commit Graph

13 Commits

Author SHA1 Message Date
Marco Bubke
a0c69c517c Utils: Fix long small string
We used only 6 bit to save the short size but for SmallString with a size
over 64 it is not enough. So we have now to use a uint16 instead of a
uint8 if the size if over 64.

Change-Id: I53558e492b6cb40b739b23a8af83d192a2e11bd2
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-31 16:12:18 +00:00
Marco Bubke
58639a4a18 Utils: Fix compile
Change-Id: Idb2c3b8123d9c34259dbb1e9089a14c251c5777d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-30 15:49:45 +00:00
Tim Jenssen
1dd407736a Utils: compile work around for MSVC 2015 update 3
Seems to be a compiler bug and can be removed if fixed in the compiler.

Change-Id: I5c1aad3b135298ced0a9b706f2aab483b04abc56
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-01-30 14:32:47 +00:00
Robert Loehning
eeb0b8fd21 Revert "Revert "Utils: Remove old compiler support code""
Thomas provided a smaller fix.
This reverts commit 78fb7f44bf.

Change-Id: I1edff6477526fe4ce29df38852f47fe49117561e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 12:21:43 +00:00
Alessandro Portale
78fb7f44bf Revert "Utils: Remove old compiler support code"
This reverts commit 8a32bcc5e7.

Broke build with MSVC 2015, update 3

Change-Id: Icb59b70fb00ea2a2ecc8d26c8177d21d82aaccf2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-01-19 11:47:26 +00:00
Marco Bubke
8a32bcc5e7 Utils: Remove old compiler support code
We now support constexpr, noexcept and alignas on all compilers. Next will
be C++ 14 constexpr support.

Change-Id: I254049c60dcd82fc373ec907cbb5702a4b344978
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-19 10:59:40 +00:00
Tim Jenssen
b31c3e0dcb Utils: Changeable SmallString stack size
The size of the small string optimization was hard coded. For some use
cases you want a bigger or smaller size. It is now configurable by a
template parameter. For that we changed the name to BasicSmallString and
added an alias of BasicSmallString<31> to SmallString.

Change-Id: I844b4420d260290307a6018bb6cc4cf3ba7bd449
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-01 16:17:21 +00:00
Marco Bubke
c8e90be9b0 Utils: Remove empty lines in smallstringlayout.h
Change-Id: I134201023bf490f92288b65177ddea7479e7601e
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-03-08 11:50:12 +00:00
Marco Bubke
68539491cd Utils: Fix compiler warning for gcc < 5.2
Change-Id: Ic6d8b6cfd9bcf09aede9295fb39832604e7bd218
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-03-08 09:00:19 +00:00
Marco Bubke
6315bd5de2 Utils: Rename hasAllocated in isReference
HasAllocated it misleading because it means that it has read only
references too. Maybe isPointing would be good too but so it is more
orthogonal to isReadOnlyReference.

Change-Id: I79aaa271aa302de2500c2ea81614e433d76f74ec
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-25 09:39:57 +00:00
Marco Bubke
e562af2c29 Utils: Rename isReference to isReadOnlyReference
There is implicit knowledge that the reference is read only in the code
so we should honor that and make is explicit.

Change-Id: I0d6eab6595ae1414ad2607760a2e02fd49bafd72
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-25 09:39:51 +00:00
Marco Bubke
d1b3259246 Utils: Fix memory layout of small string
Change-Id: Ia0509cc922b3807ffc31c278e634bab0f67d2c4d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-25 09:39:44 +00:00
Marco Bubke
1eb0c94f81 Utils: Add SmallString
SmallString is a very simple utf8 string class. It's purpose is performance.
It uses a short string opimization which provides 31 bytes of heap free
memory to save a 30 bytes long string plus null terminator. If the string
gets larger heap is allocated. The grow strategy is 1.5 to improve reuse
of allocated memory.

It uses optionally constexpr to provide string literals.

Change-Id: I7757fb51abfeca200d074cbfce2f1d99edc0ecb0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-17 15:07:01 +00:00