New internal string format:
* maximum size of a string is 2^32-1 now by default on a 64 bits system (can be increased using M_USE_STRING_LARGE_INDEX if needed). * This reduce consumption of a string_t from 24 bytes to 16 bytes. * Change the stack representation of a string, so that it lets 15 allocated bytes for the user even in 64 bytes mode. For 32 bits system, it increases to 15 allocated byte for stack representation. * synthetic performance benchmark shows a little bit of decrease of performance. But performance in real application shows a significant increase (probably due to the reduced size of the type). *Augment test suite to be sure to test all corner cases of the new representaiton.
This commit is contained in:
1 parent
bf59c53921
commit
67e9c8ff06
3 files changed
+198
-96
No files matched your search
+28
-2
@@ -765,11 +765,36 @@ static void test0(void)
|
||||
|
||||
string_init(s1);
|
||||
string_set_str(s1, "Hello");
|
||||
string_reserve(s1, 128);
|
||||
assert(string_equal_str_p(s1, "Hello"));
|
||||
for(i = 0 ; i < 2049; i++) {
|
||||
string_reserve(s1, i);
|
||||
assert(string_equal_str_p(s1, "Hello"));
|
||||
}
|
||||
string_clear(s1);
|
||||
}
|
||||
|
||||
static void test_rounding(void)
|
||||
{
|
||||
const size_t max = -(m_str1ng_size_t)1;
|
||||
for(size_t a = max/2; a <= max; a++) {
|
||||
unsigned char m, e;
|
||||
size_t x = (size_t) a + a/2;
|
||||
size_t nx = m_str1ng_round_capacity(&m, &e, (m_str1ng_size_t) x);
|
||||
if (nx >= x) {
|
||||
assert( x == (m_str1ng_size_t)x);
|
||||
}
|
||||
}
|
||||
if (max != -(size_t)1) {
|
||||
for(size_t a = max; a <= 2*max; a++) {
|
||||
unsigned char m, e;
|
||||
size_t x = (size_t) a + a/2;
|
||||
size_t nx = m_str1ng_round_capacity(&m, &e, (m_str1ng_size_t) x);
|
||||
if (nx >= x) {
|
||||
assert( x == (m_str1ng_size_t)x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_int(void)
|
||||
{
|
||||
string_t s;
|
||||
@@ -1005,6 +1030,7 @@ static void test_parse_standard_c_type(void)
|
||||
int main(void)
|
||||
{
|
||||
test0();
|
||||
test_rounding();
|
||||
test_M_LET();
|
||||
test_parse_standard_c_type();
|
||||
test_utf8_basic();
|
||||
|
||||
Reference in new issue
Block a user