macro -> inline
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 27 Feb 2010 15:38:58 +0000 (15:38 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 27 Feb 2010 15:38:58 +0000 (15:38 +0000)
clear, type checking and same runtime cost.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@46584 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_strbuf.c

index 2b262f6..a28b9e9 100644 (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.
@@ -692,13 +690,31 @@ _eina_strbuf_init(Eina_Strbuf *buf)
 /**
  * @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
+ *
  * resize the buffer
  * @param buf the buffer to resize
  * @param size the minimum size of the buffer
  *
  * @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;