From 61bc73f0711864af0006aae8ad83cf0b7faeace7 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 30 Nov 2010 08:32:59 +0200 Subject: [PATCH] * : use some gcc attributes (if applicable) for optimization --- src/mu-bookmarks.h | 9 +++++++-- src/mu-index.h | 3 ++- src/mu-msg-iter.h | 8 +++++--- src/mu-msg.h | 11 ++++------- src/mu-query.h | 26 +++++++++++++------------- src/mu-str.h | 15 +++++++-------- src/mu-util.h | 25 ++++++++++++++++--------- 7 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/mu-bookmarks.h b/src/mu-bookmarks.h index fd6def32..fdfa8f6f 100644 --- a/src/mu-bookmarks.h +++ b/src/mu-bookmarks.h @@ -20,6 +20,10 @@ #ifndef __MU_BOOKMARKS_H__ #define __MU_BOOKMARKS_H__ +#include + +G_BEGIN_DECLS + typedef struct _MuBookmarks MuBookmarks; @@ -31,8 +35,8 @@ typedef struct _MuBookmarks MuBookmarks; * * @return a new BookMarks object, or NULL in case of error */ -MuBookmarks *mu_bookmarks_new (const gchar *bmpath); - +MuBookmarks *mu_bookmarks_new (const gchar *bmpath) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * destroy a bookmarks object @@ -66,5 +70,6 @@ typedef void (*MuBookmarksForeachFunc) (const gchar *key, const gchar *val, void mu_bookmarks_foreach (MuBookmarks *bm, MuBookmarksForeachFunc func, gpointer user_data); +G_END_DECLS #endif /*__MU_BOOKMARKS_H__*/ diff --git a/src/mu-index.h b/src/mu-index.h index 6ec1f3f0..86b86402 100644 --- a/src/mu-index.h +++ b/src/mu-index.h @@ -51,7 +51,8 @@ typedef struct _MuIndexStats MuIndexStats; * * @return a new MuIndex instance, or NULL in case of error */ -MuIndex* mu_index_new (const char* muhome, GError **err); +MuIndex* mu_index_new (const char* muhome, GError **err) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** diff --git a/src/mu-msg-iter.h b/src/mu-msg-iter.h index d9979ce0..cf74e936 100644 --- a/src/mu-msg-iter.h +++ b/src/mu-msg-iter.h @@ -20,7 +20,8 @@ #ifndef __MU_MSG_ITER_H__ #define __MU_MSG_ITER_H__ -#include "mu-msg.h" +#include +#include G_BEGIN_DECLS @@ -73,8 +74,9 @@ void mu_msg_iter_destroy (MuMsgIter *iter); * @return a MuMsgGMime instance, or NULL in case of error. Use * mu_msg_gmime_destroy when the instance is no longer needed */ -MuMsg* mu_msg_iter_get_msg (MuMsgIter *iter, GError **err); - +MuMsg* mu_msg_iter_get_msg (MuMsgIter *iter, GError **err) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + /** * get the document id for the current message * diff --git a/src/mu-msg.h b/src/mu-msg.h index 8ff51981..45e38f0e 100644 --- a/src/mu-msg.h +++ b/src/mu-msg.h @@ -63,10 +63,8 @@ void mu_msg_gmime_uninit (void); * * @return a new MuMsg instance or NULL in case of error */ -MuMsg* mu_msg_new (const char* filepath, - const char *maildir, - GError **err); - +MuMsg *mu_msg_new (const char* filepath, const char *maildir, + GError **err) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * destroy a MuMsg* instance; call this function when done with @@ -126,9 +124,8 @@ const char* mu_msg_get_summary (MuMsg *msg, size_t max_lines); * * @return TRUE if saving succeeded, FALSE otherwise */ -gboolean -mu_msg_mime_part_save (MuMsg *msg, unsigned wanted_idx, - const char *targetdir, gboolean overwrite); +gboolean mu_msg_mime_part_save (MuMsg *msg, unsigned wanted_idx, + const char *targetdir, gboolean overwrite); /** * get the sender (From:) of this message diff --git a/src/mu-query.h b/src/mu-query.h index 1d965645..d5686ee5 100644 --- a/src/mu-query.h +++ b/src/mu-query.h @@ -42,7 +42,8 @@ typedef struct _MuQuery MuQuery; * when the instance is no longer needed, use mu_query_destroy * to free it */ -MuQuery *mu_query_new (const char* path, GError **err) G_GNUC_WARN_UNUSED_RESULT; +MuQuery *mu_query_new (const char* path, GError **err) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * destroy the MuQuery instance @@ -59,7 +60,8 @@ void mu_query_destroy (MuQuery *self); * * @return the version string (free with g_free), or NULL in case of error */ -char* mu_query_version (MuQuery *store) G_GNUC_WARN_UNUSED_RESULT; +char* mu_query_version (MuQuery *store) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * run a Xapian query; for the syntax, please refer to the mu-find @@ -82,12 +84,10 @@ char* mu_query_version (MuQuery *store) G_GNUC_WARN_UNUSED_RESULT; * @return a MuMsgIter instance you can iterate over, or NULL in * case of error */ -MuMsgIter* mu_query_run (MuQuery *self, - const char* expr, - MuMsgFieldId sortfieldid, - gboolean ascending, - size_t batchsize, - GError **err) G_GNUC_WARN_UNUSED_RESULT; +MuMsgIter* mu_query_run (MuQuery *self, const char* expr, + MuMsgFieldId sortfieldid, gboolean ascending, + size_t batchsize, GError **err) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * get a string representation of the Xapian search query @@ -100,9 +100,9 @@ MuMsgIter* mu_query_run (MuQuery *self, * @return the string representation of the xapian query, or NULL in case of * error; free the returned value with g_free */ -char* mu_query_as_string (MuQuery *self, - const char* searchexpr, GError **err) G_GNUC_WARN_UNUSED_RESULT; - +char* mu_query_as_string (MuQuery *self, const char* searchexpr, GError **err) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + /** * pre-process the query; this function is useful mainly for debugging mu * @@ -110,8 +110,8 @@ char* mu_query_as_string (MuQuery *self, * * @return a pre-processed query, free it with g_free */ -char* mu_query_preprocess (const char *query) G_GNUC_WARN_UNUSED_RESULT; - +char* mu_query_preprocess (const char *query) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS diff --git a/src/mu-str.h b/src/mu-str.h index 6b1ce986..28d47feb 100644 --- a/src/mu-str.h +++ b/src/mu-str.h @@ -115,8 +115,8 @@ char* mu_str_size (size_t s) G_GNUC_WARN_UNUSED_RESULT; * for what to do with it */ const char* mu_str_flags_s (MuMsgFlags flags) G_GNUC_CONST; -char* mu_str_flags (MuMsgFlags flags) G_GNUC_WARN_UNUSED_RESULT; - +char* mu_str_flags (MuMsgFlags flags) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * get a 'summary' of the string, ie. the first /n/ lines of the @@ -127,10 +127,8 @@ char* mu_str_flags (MuMsgFlags flags) G_GNUC_WARN_UNUSED_RESULT; * * @return a newly allocated string with the summary. use g_free to free it. */ -char* mu_str_summarize (const char* str, - size_t max_lines) G_GNUC_WARN_UNUSED_RESULT; - - +char* mu_str_summarize (const char* str, size_t max_lines) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * normalize a string (ie., collapse accented characters etc.), and @@ -142,7 +140,9 @@ char* mu_str_summarize (const char* str, * * @return the normalize string, or NULL in case of error or str was NULL */ -char* mu_str_normalize (const char *str, gboolean downcase); +char* mu_str_normalize (const char *str, gboolean downcase) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; + /** @@ -159,7 +159,6 @@ char* mu_str_normalize (const char *str, gboolean downcase); */ char* mu_str_normalize_in_place (char *str, gboolean downcase); - /** * escape the string for use with xapian matching. in practice, if the * string contains an '@', replace '@', single-'.' with '_'. Also, diff --git a/src/mu-util.h b/src/mu-util.h index e7fa216d..06cf433a 100644 --- a/src/mu-util.h +++ b/src/mu-util.h @@ -40,7 +40,8 @@ gboolean mu_util_init_system (void); * @return the expanded path as a newly allocated string, or NULL in * case of error */ -char* mu_util_dir_expand (const char* path) G_GNUC_WARN_UNUSED_RESULT; +char* mu_util_dir_expand (const char* path) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * guess the maildir; first try $MAILDIR; if it is unset or @@ -48,7 +49,8 @@ char* mu_util_dir_expand (const char* path) G_GNUC_WARN_UNUSED_RESULT; * * @return full path of the guessed Maildir, or NULL; must be freed (gfree) */ -char* mu_util_guess_maildir (void) G_GNUC_WARN_UNUSED_RESULT; +char* mu_util_guess_maildir (void) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** @@ -59,7 +61,8 @@ char* mu_util_guess_maildir (void) G_GNUC_WARN_UNUSED_RESULT; * @return the guessed mu homedir, which needs to be freed with g_free * when no longer needed. */ -gchar* mu_util_guess_mu_homedir (void); +gchar* mu_util_guess_mu_homedir (void) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** * if path exists, check that's a read/writeable dir; otherwise try to @@ -70,7 +73,8 @@ gchar* mu_util_guess_mu_homedir (void); * @return TRUE if a read/writeable directory `path' exists after * leaving this function, FALSE otherwise */ -gboolean mu_util_create_dir_maybe (const gchar *path) G_GNUC_WARN_UNUSED_RESULT; +gboolean mu_util_create_dir_maybe (const gchar *path) + G_GNUC_WARN_UNUSED_RESULT; /** @@ -84,7 +88,8 @@ gboolean mu_util_create_dir_maybe (const gchar *path) G_GNUC_WARN_UNUSED_RESULT; * @return TRUE if dir exist and has the specified properties */ gboolean mu_util_check_dir (const gchar* path, gboolean readable, - gboolean writeable) G_GNUC_WARN_UNUSED_RESULT; + gboolean writeable) + G_GNUC_WARN_UNUSED_RESULT; @@ -97,11 +102,12 @@ gboolean mu_util_check_dir (const gchar* path, gboolean readable, * @param overwrite should we allow for overwriting existing files? * * @return a file descriptor, or -1 in case of error. If it's a fily - * system error, 'errno' may have more info. + * system error, 'errno' may have more info. use 'close()' when done + * with the file descriptor */ int mu_util_create_writeable_fd (const char* filename, const char* dir, - gboolean overwrite); - + gboolean overwrite) + G_GNUC_WARN_UNUSED_RESULT; /** * convert a string array in to a string, with the elements separated @@ -111,7 +117,8 @@ int mu_util_create_writeable_fd (const char* filename, const char* dir, * * @return a newly allocated string */ -gchar* mu_util_str_from_strv (const gchar **params) G_GNUC_WARN_UNUSED_RESULT; +gchar* mu_util_str_from_strv (const gchar **params) + G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; /** *