There's no need to dereference array->element_size and
perform a division when all you care about is the boolean
isempty/nonempty predicate:
$ git grep 'array_count(.*) > 0' | wc -l
77
$ git grep 'array_count(.*) == 0' | wc -l
95
Changing 6 of them has the following impact on the code:
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20879 0 4 20883 5193 src/lib-imap-client/imapc-connection.o
$ size src/lib-imap-client/imapc-connection.o
text data bss dec hex filename
20796 0 4 20800 5140 src/lib-imap-client/imapc-connection.o
Signed-off-by: Phil Carmody <phil@dovecot.fi>
}
#define array_count(array) \
array_count_i(&(array)->arr)
+/* No need for the real count if all we're doing is comparing againts 0 */
+#define array_is_empty(array) \
+ ((array)->arr.buffer->used == 0)
+#define array_not_empty(array) \
+ ((array)->arr.buffer->used > 0)
static inline void
array_append_i(struct array *array, const void *data, unsigned int count)