提交 af274507 编写于 作者: B Behdad Esfahbod

Minor

上级 570d5237
...@@ -425,14 +425,13 @@ struct hb_prealloced_array_t ...@@ -425,14 +425,13 @@ struct hb_prealloced_array_t
return &array[len - 1]; return &array[len - 1];
} }
// Alloc enouch for size if size < allocated. Don't adjust len. /* Allocate for size but don't adjust len. */
inline bool alloc(unsigned int size) inline bool alloc(unsigned int size)
{ {
if (likely (size <= allocated)) if (likely (size <= allocated))
{
return true; return true;
}
/* Need to reallocate */ /* Reallocate */
unsigned int new_allocated = allocated; unsigned int new_allocated = allocated;
while (size >= new_allocated) while (size >= new_allocated)
...@@ -462,10 +461,8 @@ struct hb_prealloced_array_t ...@@ -462,10 +461,8 @@ struct hb_prealloced_array_t
inline bool resize (unsigned int size) inline bool resize (unsigned int size)
{ {
if (!alloc(size)) if (!alloc (size))
{
return false; return false;
}
len = size; len = size;
return true; return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册