macro -> inline

clear, type checking and same runtime cost.



SVN revision: 46584
This commit is contained in:
Gustavo Sverzut Barbieri 2010-02-27 15:38:58 +00:00
parent 66ff799e5e
commit 4d9ed8cb79
1 changed files with 21 additions and 5 deletions

View File

@ -43,12 +43,10 @@ struct _Eina_Strbuf
};
static Eina_Bool _eina_strbuf_init(Eina_Strbuf *buf);
static Eina_Bool _eina_strbuf_resize(Eina_Strbuf *buf, size_t size);
static inline Eina_Bool _eina_strbuf_grow(Eina_Strbuf *buf, size_t size);
static inline Eina_Bool _eina_strbuf_resize(Eina_Strbuf *buf, size_t size);
static inline Eina_Bool _eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t len, size_t pos);
#define _eina_strbuf_grow(_buf, _size) \
((((_size) + 1) > (_buf)->size) ? _eina_strbuf_resize((_buf), (_size)) : EINA_TRUE)
/**
* @internal
* @brief Initialize the strbuf module.
@ -689,6 +687,24 @@ _eina_strbuf_init(Eina_Strbuf *buf)
return EINA_TRUE;
}
/**
* @internal
*
* If required, enlarge the buffer to fit the new size.
*
* @param buf the buffer to resize
* @param size the minimum size of the buffer
*
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
static inline Eina_Bool
_eina_strbuf_grow(Eina_Strbuf *buf, size_t size)
{
if ((size + 1) < buf->size)
return EINA_TRUE;
return _eina_strbuf_resize(buf, size);
}
/**
* @internal
*
@ -698,7 +714,7 @@ _eina_strbuf_init(Eina_Strbuf *buf)
*
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*/
static Eina_Bool
static inline Eina_Bool
_eina_strbuf_resize(Eina_Strbuf *buf, size_t size)
{
char *buffer;