Update code after benching empty creation of string.
This commit is contained in:
1 parent
05ae9f382b
commit
b091f84f90
1 file changed
+9
-5
+9
-5
@@ -94,11 +94,15 @@ static inline void
|
|||||||
string_clear(string_t v)
|
string_clear(string_t v)
|
||||||
{
|
{
|
||||||
STRINGI_CONTRACT(v);
|
STRINGI_CONTRACT(v);
|
||||||
M_MEMORY_FREE(v->ptr);
|
if (M_LIKELY(v->ptr)) {
|
||||||
/* This is not needed but is safer. size is not set to make
|
/* Even free supports NULL argument, bench shows there is quite a high
|
||||||
the string more or less invalid so that it can be detected. */
|
cost to call free. This is an impact for empty string. */
|
||||||
v->alloc = 0;
|
M_MEMORY_FREE(v->ptr);
|
||||||
v->ptr = NULL;
|
/* This is not needed but is safer. size is not set to make
|
||||||
|
the string more or less invalid so that it can be detected. */
|
||||||
|
v->alloc = 0;
|
||||||
|
v->ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: Internaly used by STRING_DECL_INIT */
|
/* NOTE: Internaly used by STRING_DECL_INIT */
|
||||||
|
|||||||
Reference in new issue
Block a user