Changeset 212

Show
Ignore:
Timestamp:
05/03/06 12:08:06
Author:
pvanhoof
Message:

Memory and loading improvements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-camel/tny-account.c

    r202 r212  
    394394        static GType type = 0; 
    395395 
    396         if (!camel_type_init_done
     396        if (G_UNLIKELY (!camel_type_init_done)
    397397        { 
    398398                camel_type_init (); 
     
    400400        } 
    401401 
    402         if (type == 0)  
     402        if (G_UNLIKELY(type == 0)) 
    403403        { 
    404404                static const GTypeInfo info =  
  • trunk/libtinymail-camel/tny-camel-stream.c

    r209 r212  
    150150        static CamelType type = CAMEL_INVALID_TYPE; 
    151151         
    152         if (!camel_type_init_done
     152        if (G_UNLIKELY (!camel_type_init_done)
    153153        { 
    154154                camel_type_init (); 
     
    156156        } 
    157157 
    158         if (type == CAMEL_INVALID_TYPE) { 
     158        if (G_UNLIKELY (type == CAMEL_INVALID_TYPE))  
     159        { 
    159160                parent_class = (CamelStreamClass *)camel_stream_get_type(); 
    160161                type = camel_type_register ((CamelType)parent_class, 
  • trunk/libtinymail-camel/tny-msg-folder-priv.h

    r196 r212  
    5555 
    5656void _tny_msg_folder_set_subscribed_priv (TnyMsgFolderIface *self, gboolean subscribed); 
     57void _tny_msg_folder_set_name_priv (TnyMsgFolderIface *self, const gchar *name); 
    5758 
    5859#endif 
  • trunk/libtinymail-camel/tny-msg-folder.c

    r209 r212  
    498498        const gchar *name = NULL; 
    499499         
    500         load_folder (priv); 
    501  
    502500        if (!priv->cached_name) 
     501        { 
     502                load_folder (priv); 
    503503                name = camel_folder_get_name (priv->folder); 
    504         else 
     504        } else 
    505505                name = priv->cached_name; 
    506506 
     
    525525 
    526526        priv->folder_name = g_strdup (id); 
     527 
     528        return; 
     529} 
     530 
     531 
     532void 
     533_tny_msg_folder_set_name_priv (TnyMsgFolderIface *self, const gchar *name) 
     534{ 
     535        TnyMsgFolderPriv *priv = TNY_MSG_FOLDER_GET_PRIVATE (TNY_MSG_FOLDER (self)); 
     536 
     537        if (priv->cached_name) 
     538                g_free (priv->cached_name); 
     539 
     540        priv->cached_name = g_strdup (name); 
    527541 
    528542        return; 
     
    774788        static GType type = 0; 
    775789 
    776         if (!camel_type_init_done
     790        if (G_UNLIKELY (!camel_type_init_done)
    777791        { 
    778792                camel_type_init (); 
     
    780794        } 
    781795 
    782         if (type == 0)  
     796        if (G_UNLIKELY(type == 0)) 
    783797        { 
    784798                static const GTypeInfo info =  
  • trunk/libtinymail-camel/tny-msg-header.c

    r186 r212  
    6666unload_msg_header (TnyMsgHeader *self) 
    6767{ 
    68         if (!self->uncachable
     68        if (G_UNLIKELY (!self->uncachable)
    6969                return; 
    7070 
    71         if (self->mime_from) 
     71        if (G_LIKELY (self->mime_from)) 
     72        { 
    7273                g_free (self->mime_from); 
    73         self->mime_from = NULL; 
    74  
    75         if (self->use_summary) 
     74                self->mime_from = NULL; 
     75        } 
     76 
     77        if (G_LIKELY (self->use_summary)) 
    7678        { 
    77                 if (self->message_info)  
     79                if (G_LIKELY (self->message_info)) 
     80                { 
    7881                        camel_message_info_free (self->message_info); 
    79                 self->message_info = NULL; 
     82                        self->message_info = NULL; 
     83                } 
    8084        } else { 
    81                 if (self->mime_message && CAMEL_IS_OBJECT (self->mime_message)) 
    82                         camel_object_unref (CAMEL_OBJECT (self->mime_message)); 
     85                if (G_LIKELY (self->mime_message) && G_LIKELY (CAMEL_IS_OBJECT (self->mime_message))) 
     86                        camel_object_unref (CAMEL_OBJECT (self->mime_message));         
    8387                self->mime_message = NULL; 
    8488        } 
     
    101105load_msg_header (TnyMsgHeader *self) 
    102106{ 
    103         if (!self->uncachable
     107        if (G_UNLIKELY (!self->uncachable)
    104108                return; 
    105109 
    106         if (self->use_summary
     110        if (G_LIKELY (self->use_summary)
    107111        { 
    108                 if (!self->message_info && self->folder && self->uid
     112                if (G_LIKELY (!self->message_info) && G_LIKELY (self->folder) && G_LIKELY (self->uid)
    109113                { 
    110114                        CamelFolder *folder = _tny_msg_folder_get_camel_folder (self->folder); 
     
    113117                        _tny_msg_header_set_camel_message_info (self, msginfo); 
    114118                } 
    115         } else  
    116         { 
    117                 if (!self->mime_message && self->folder && self->uid) 
     119        } else { 
     120                if (G_LIKELY (!self->mime_message) && G_LIKELY (self->folder) && G_LIKELY (self->uid)) 
    118121                { 
    119122                        CamelFolder *folder = _tny_msg_folder_get_camel_folder (self->folder); 
     
    134137        self->use_summary = FALSE; 
    135138 
    136         if (!self->mime_message
     139        if (G_LIKELY (!self->mime_message)
    137140                self->mime_message = camel_mime_message_new (); 
    138141 
     
    146149{ 
    147150 
    148         if (self->message_info
     151        if (G_UNLIKELY (self->message_info)
    149152                g_warning ("Strange behaviour: Overwriting existing message info"); 
    150153 
     
    168171{ 
    169172 
    170         if (self->mime_message
     173        if (G_UNLIKELY (self->mime_message)
    171174                g_warning ("Strange behaviour: Overwriting existing MIME message"); 
    172175 
     
    195198        TnyMsgHeader *me = TNY_MSG_HEADER (self); 
    196199 
    197         g_mutex_lock (me->hdr_lock); 
    198         if (me->folder) 
     200        if (G_UNLIKELY (me->folder)) 
    199201                g_warning ("Strange behaviour: Overwriting existing folder"); 
    200202 
     203        g_mutex_lock (me->hdr_lock); 
    201204        me->folder = (TnyMsgFolderIface*)folder; 
    202205        g_mutex_unlock (me->hdr_lock); 
     
    358361        load_msg_header (me); 
    359362 
    360         if (me->use_summary && me->message_info
     363        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    361364                retval = camel_message_info_cc (me->message_info); 
    362         else if (me->mime_message
     365        else if (G_LIKELY (me->mime_message)
    363366                retval = camel_medium_get_header (CAMEL_MEDIUM (me->mime_message), "cc"); 
    364367 
    365         if (!retval
     368        if (G_UNLIKELY (!retval)
    366369                retval = me->invalid; 
    367370 
     
    382385        load_msg_header (me); 
    383386 
    384         if (me->use_summary) /* TODO */ 
     387        if (G_LIKELY (me->use_summary)) /* TODO */ 
    385388                retval = me->invalid; 
    386         else if (me->mime_message
     389        else if (G_LIKELY (me->mime_message)
    387390                retval = camel_medium_get_header (CAMEL_MEDIUM (me->mime_message), "bcc"); 
    388391 
    389         if (!retval
     392        if (G_UNLIKELY (!retval)
    390393                retval = me->invalid; 
    391394 
     
    406409        load_msg_header (me); 
    407410 
    408         if (me->use_summary && me->message_info
     411        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    409412                retval = camel_message_info_date_received (me->message_info); 
    410         else if (me->mime_message
     413        else if (G_LIKELY (me->mime_message)
    411414                retval = camel_mime_message_get_date_received (me->mime_message, NULL); 
    412415 
     
    427430        load_msg_header (me); 
    428431 
    429         if (me->use_summary && me->message_info
     432        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    430433                retval = camel_message_info_date_sent (me->message_info); 
    431434        else { 
     
    449452        load_msg_header (me); 
    450453 
    451         if (me->use_summary && me->message_info
     454        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    452455                retval = camel_message_info_from (me->message_info); 
    453456        else 
    454457        { 
    455                 if (!me->mime_from && me->mime_message
     458                if (G_LIKELY (!me->mime_from) && G_LIKELY (me->mime_message)
    456459                { 
    457460                        CamelInternetAddress *addr = (CamelInternetAddress*) 
     
    464467        } 
    465468 
    466         if (!retval
     469        if (G_UNLIKELY (!retval)
    467470                retval = me->invalid; 
    468471 
     
    482485        load_msg_header (me); 
    483486 
    484         if (me->use_summary && me->message_info
     487        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    485488                retval = camel_message_info_subject (me->message_info); 
    486         else if (me->mime_message
     489        else if (G_LIKELY (me->mime_message)
    487490                retval = camel_mime_message_get_subject (me->mime_message); 
    488491 
    489         if (!retval
     492        if (G_UNLIKELY (!retval)
    490493                retval = me->invalid; 
    491494 
     
    507510        load_msg_header (me); 
    508511 
    509         if (me->use_summary && me->message_info
     512        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    510513                retval = camel_message_info_to (me->message_info); 
    511         else if (me->mime_message
     514        else if (G_LIKELY (me->mime_message)
    512515                retval = camel_medium_get_header (CAMEL_MEDIUM (me->mime_message), "to"); 
    513516 
    514         if (!retval
     517        if (G_UNLIKELY (!retval)
    515518                retval = me->invalid; 
    516519 
     
    531534        load_msg_header (me); 
    532535 
    533         if (me->use_summary && me->message_info
     536        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    534537                retval = (const gchar*)camel_message_info_message_id (me->message_info); 
    535         else if (me->mime_message
     538        else if (G_LIKELY (me->mime_message)
    536539                retval = camel_mime_message_get_message_id (me->mime_message); 
    537540 
    538         if (!retval
     541        if (G_UNLIKELY (!retval)
    539542                retval = me->invalid; 
    540543 
     
    557560        load_msg_header (me); 
    558561 
    559         if (me->use_summary && me->message_info
     562        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    560563                retval = camel_message_info_uid (me->message_info); 
    561564        else /* Bleh solution ... */ 
     
    583586        /* Yes I know what I'm doing, also check tny-msg-folder.c */ 
    584587 
    585         if (me->use_summary)  
     588        if (G_LIKELY (me->use_summary)) 
    586589                me->uid = (gchar*)uid; 
    587590        else { 
     
    611614        g_mutex_lock (me->hdr_lock); 
    612615 
    613         if (me->use_summary
     616        if (G_LIKELY (me->use_summary)
    614617                retval = (me->message_info != NULL); 
    615618        else 
     
    628631        g_mutex_lock (me->hdr_lock); 
    629632 
    630         if (me->use_summary && me->message_info
     633        if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info)
    631634                unload_msg_header (me); 
    632635 
    633         if (!me->use_summary && me->mime_message
     636        if (G_UNLIKELY (!me->use_summary) && G_LIKELY (me->mime_message)
    634637                unload_msg_header (me); 
    635638 
     
    650653        self->uncachable = TRUE; 
    651654 
    652         if (self->use_summary && self->message_info
     655        if (G_LIKELY (self->use_summary) && G_LIKELY (self->message_info)
    653656                unload_msg_header (self); 
    654657 
    655         if (!self->use_summary && self->mime_message
     658        if (G_UNLIKELY (!self->use_summary) && G_LIKELY (self->mime_message)
    656659                unload_msg_header (self); 
    657660 
    658661        /* Indeed, check the speedup trick above */ 
    659         if (self->uid && !self->use_summary
     662        if (G_LIKELY (self->uid) && G_UNLIKELY (!self->use_summary)
    660663                g_free (self->uid); /* Also check above */ 
    661664 
     
    744747        static GType type = 0; 
    745748 
    746         if (!camel_type_init_done
     749        if (G_UNLIKELY (!camel_type_init_done)
    747750        { 
    748751                camel_type_init (); 
     
    750753        } 
    751754 
    752         if (type == 0)  
     755        if (G_UNLIKELY(type == 0)) 
    753756        { 
    754757                static const GTypeInfo info =  
  • trunk/libtinymail-camel/tny-msg-mime-part.c

    r209 r212  
    5050        wrapper = camel_medium_get_content_object (medium); 
    5151 
    52         if (!wrapper
     52        if (G_UNLIKELY (!wrapper)
    5353        { 
    5454                g_error ("Mime part does not yet have a source stream, use " 
     
    8989        wrapper = camel_medium_get_content_object (medium); 
    9090 
    91         if (wrapper
     91        if (G_LIKELY (wrapper)
    9292                camel_object_unref (CAMEL_OBJECT (wrapper)); 
    9393 
     
    121121        wrapper = camel_medium_get_content_object (medium); 
    122122 
    123         if (!wrapper
     123        if (G_UNLIKELY (!wrapper)
    124124        { 
    125125                wrapper = camel_data_wrapper_new ();  
     
    145145        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    146146 
    147         if (!priv->cached_content_type
     147        if (G_LIKELY (!priv->cached_content_type)
    148148        { 
    149149                CamelContentType *type; 
     
    199199        g_mutex_lock (priv->part_lock); 
    200200 
     201        if (G_UNLIKELY (priv->cached_content_type)) 
     202                g_free (priv->cached_content_type); 
     203        priv->cached_content_type = NULL; 
     204        if (G_UNLIKELY (priv->part)) 
     205                camel_object_unref (CAMEL_OBJECT (priv->part)); 
     206        camel_object_ref (CAMEL_OBJECT (part)); 
     207        priv->part = part; 
     208 
     209        g_mutex_unlock (priv->part_lock); 
     210 
     211        return; 
     212} 
     213 
     214CamelMimePart* 
     215tny_msg_mime_part_get_part (TnyMsgMimePart *self) 
     216{ 
     217        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     218        CamelMimePart *retval; 
     219 
     220        g_mutex_lock (priv->part_lock); 
     221        retval = priv->part; 
     222        g_mutex_unlock (priv->part_lock); 
     223 
     224        return retval; 
     225} 
     226 
     227 
     228static const gchar* 
     229tny_msg_mime_part_get_filename (TnyMsgMimePartIface *self) 
     230{ 
     231        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     232        const gchar *retval; 
     233 
     234        g_mutex_lock (priv->part_lock); 
     235        retval = camel_mime_part_get_filename (priv->part); 
     236        g_mutex_unlock (priv->part_lock); 
     237         
     238        return retval; 
     239} 
     240 
     241static const gchar* 
     242tny_msg_mime_part_get_content_id (TnyMsgMimePartIface *self) 
     243{ 
     244        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     245        const gchar *retval; 
     246 
     247        g_mutex_lock (priv->part_lock); 
     248        retval = camel_mime_part_get_content_id (priv->part); 
     249        g_mutex_unlock (priv->part_lock); 
     250 
     251        return retval; 
     252} 
     253 
     254static const gchar* 
     255tny_msg_mime_part_get_description (TnyMsgMimePartIface *self) 
     256{ 
     257        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     258        const gchar *retval; 
     259 
     260        g_mutex_lock (priv->part_lock); 
     261        retval = camel_mime_part_get_description (priv->part); 
     262        g_mutex_unlock (priv->part_lock); 
     263 
     264        return retval; 
     265} 
     266 
     267static const gchar* 
     268tny_msg_mime_part_get_content_location (TnyMsgMimePartIface *self) 
     269{ 
     270        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     271        const gchar *retval; 
     272 
     273        g_mutex_lock (priv->part_lock); 
     274        retval = camel_mime_part_get_content_location (priv->part); 
     275        g_mutex_unlock (priv->part_lock); 
     276 
     277        return retval; 
     278} 
     279 
     280 
     281static void  
     282tny_msg_mime_part_set_content_location (TnyMsgMimePartIface *self, const gchar *content_location) 
     283{ 
     284        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     285 
     286        g_mutex_lock (priv->part_lock); 
     287        camel_mime_part_set_content_location (priv->part, content_location); 
     288        g_mutex_unlock (priv->part_lock); 
     289 
     290        return; 
     291} 
     292 
     293static void  
     294tny_msg_mime_part_set_description (TnyMsgMimePartIface *self, const gchar *description) 
     295{ 
     296        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     297 
     298        g_mutex_lock (priv->part_lock); 
     299        camel_mime_part_set_description (priv->part, description); 
     300        g_mutex_unlock (priv->part_lock); 
     301 
     302        return; 
     303} 
     304 
     305static void  
     306tny_msg_mime_part_set_content_id (TnyMsgMimePartIface *self, const gchar *content_id) 
     307{ 
     308        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     309 
     310        g_mutex_lock (priv->part_lock); 
     311        camel_mime_part_set_content_id (priv->part, content_id); 
     312        g_mutex_unlock (priv->part_lock); 
     313 
     314        return; 
     315} 
     316 
     317static void  
     318tny_msg_mime_part_set_filename (TnyMsgMimePartIface *self, const gchar *filename) 
     319{ 
     320        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     321 
     322        g_mutex_lock (priv->part_lock); 
     323        camel_mime_part_set_filename (priv->part, filename); 
     324        g_mutex_unlock (priv->part_lock); 
     325 
     326        return; 
     327} 
     328 
     329static void  
     330tny_msg_mime_part_set_content_type (TnyMsgMimePartIface *self, const gchar *content_type) 
     331{ 
     332        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     333 
     334        g_mutex_lock (priv->part_lock); 
     335 
     336        camel_mime_part_set_content_type (priv->part, content_type); 
     337        if (G_UNLIKELY (priv->cached_content_type)) 
     338                g_free (priv->cached_content_type); 
     339        priv->cached_content_type = NULL; 
     340 
     341        g_mutex_unlock (priv->part_lock); 
     342 
     343        return; 
     344} 
     345 
     346static void 
     347tny_msg_mime_part_finalize (GObject *object) 
     348{ 
     349        TnyMsgMimePart *self = (TnyMsgMimePart*) object; 
     350        TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
     351 
     352        g_mutex_lock (priv->part_lock); 
    201353        if (priv->cached_content_type) 
    202354                g_free (priv->cached_content_type); 
    203355        priv->cached_content_type = NULL; 
    204         if (priv->part) 
    205                 camel_object_unref (CAMEL_OBJECT (priv->part)); 
    206         camel_object_ref (CAMEL_OBJECT (part)); 
    207         priv->part = part; 
    208  
    209         g_mutex_unlock (priv->part_lock); 
    210  
    211         return; 
    212 
    213  
    214 CamelMimePart* 
    215 tny_msg_mime_part_get_part (TnyMsgMimePart *self) 
    216 
    217         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    218         CamelMimePart *retval; 
    219  
    220         g_mutex_lock (priv->part_lock); 
    221         retval = priv->part; 
    222         g_mutex_unlock (priv->part_lock); 
    223  
    224         return retval; 
    225 
    226  
    227  
    228 static const gchar* 
    229 tny_msg_mime_part_get_filename (TnyMsgMimePartIface *self) 
    230 
    231         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    232         const gchar *retval; 
    233  
    234         g_mutex_lock (priv->part_lock); 
    235         retval = camel_mime_part_get_filename (priv->part); 
    236         g_mutex_unlock (priv->part_lock); 
    237          
    238         return retval; 
    239 
    240  
    241 static const gchar* 
    242 tny_msg_mime_part_get_content_id (TnyMsgMimePartIface *self) 
    243 
    244         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    245         const gchar *retval; 
    246  
    247         g_mutex_lock (priv->part_lock); 
    248         retval = camel_mime_part_get_content_id (priv->part); 
    249         g_mutex_unlock (priv->part_lock); 
    250  
    251         return retval; 
    252 
    253  
    254 static const gchar* 
    255 tny_msg_mime_part_get_description (TnyMsgMimePartIface *self) 
    256 
    257         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    258         const gchar *retval; 
    259  
    260         g_mutex_lock (priv->part_lock); 
    261         retval = camel_mime_part_get_description (priv->part); 
    262         g_mutex_unlock (priv->part_lock); 
    263  
    264         return retval; 
    265 
    266  
    267 static const gchar* 
    268 tny_msg_mime_part_get_content_location (TnyMsgMimePartIface *self) 
    269 
    270         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    271         const gchar *retval; 
    272  
    273         g_mutex_lock (priv->part_lock); 
    274         retval = camel_mime_part_get_content_location (priv->part); 
    275         g_mutex_unlock (priv->part_lock); 
    276  
    277         return retval; 
    278 
    279  
    280  
    281 static void  
    282 tny_msg_mime_part_set_content_location (TnyMsgMimePartIface *self, const gchar *content_location) 
    283 
    284         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    285  
    286         g_mutex_lock (priv->part_lock); 
    287         camel_mime_part_set_content_location (priv->part, content_location); 
    288         g_mutex_unlock (priv->part_lock); 
    289  
    290         return; 
    291 
    292  
    293 static void  
    294 tny_msg_mime_part_set_description (TnyMsgMimePartIface *self, const gchar *description) 
    295 
    296         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    297  
    298         g_mutex_lock (priv->part_lock); 
    299         camel_mime_part_set_description (priv->part, description); 
    300         g_mutex_unlock (priv->part_lock); 
    301  
    302         return; 
    303 
    304  
    305 static void  
    306 tny_msg_mime_part_set_content_id (TnyMsgMimePartIface *self, const gchar *content_id) 
    307 
    308         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    309  
    310         g_mutex_lock (priv->part_lock); 
    311         camel_mime_part_set_content_id (priv->part, content_id); 
    312         g_mutex_unlock (priv->part_lock); 
    313  
    314         return; 
    315 
    316  
    317 static void  
    318 tny_msg_mime_part_set_filename (TnyMsgMimePartIface *self, const gchar *filename) 
    319 
    320         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    321  
    322         g_mutex_lock (priv->part_lock); 
    323         camel_mime_part_set_filename (priv->part, filename); 
    324         g_mutex_unlock (priv->part_lock); 
    325  
    326         return; 
    327 
    328  
    329 static void  
    330 tny_msg_mime_part_set_content_type (TnyMsgMimePartIface *self, const gchar *content_type) 
    331 
    332         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    333  
    334         g_mutex_lock (priv->part_lock); 
    335  
    336         camel_mime_part_set_content_type (priv->part, content_type); 
    337         if (priv->cached_content_type) 
    338                 g_free (priv->cached_content_type); 
    339         priv->cached_content_type = NULL; 
    340  
    341         g_mutex_unlock (priv->part_lock); 
    342  
    343         return; 
    344 
    345  
    346 static void 
    347 tny_msg_mime_part_finalize (GObject *object) 
    348 
    349         TnyMsgMimePart *self = (TnyMsgMimePart*) object; 
    350         TnyMsgMimePartPriv *priv = TNY_MSG_MIME_PART_GET_PRIVATE (self); 
    351  
    352         g_mutex_lock (priv->part_lock); 
    353         if (priv->cached_content_type) 
    354                 g_free (priv->cached_content_type); 
    355         priv->cached_content_type = NULL; 
    356         g_mutex_unlock (priv->part_lock); 
    357  
    358         if (priv->part) 
     356        g_mutex_unlock (priv->part_lock); 
     357 
     358        if (G_LIKELY (priv->part)) 
    359359        { 
    360360                g_mutex_lock (priv->part_lock); 
     
    446446        static GType type = 0; 
    447447 
    448         if (!camel_type_init_done
     448        if (G_UNLIKELY (!camel_type_init_done)
    449449        { 
    450450                camel_type_init (); 
     
    452452        } 
    453453 
    454         if (type == 0)  
     454        if (G_UNLIKELY(type == 0)) 
    455455        { 
    456456                static const GTypeInfo info =  
  • trunk/libtinymail-camel/tny-msg.c

    r209 r212  
    5555        containee = camel_medium_get_content_object (CAMEL_MEDIUM (part)); 
    5656 
    57         if (containee == NULL
     57        if (G_UNLIKELY (containee == NULL)
    5858                return go; 
    5959 
    60         if (CAMEL_IS_MULTIPART (containee))  
     60        if (G_LIKELY (CAMEL_IS_MULTIPART (containee))) 
    6161        { 
    6262                parts = camel_multipart_get_number (CAMEL_MULTIPART (containee)); 
     
    6767                } 
    6868 
    69         } else if (CAMEL_IS_MIME_MESSAGE (containee))  
     69        } else if (G_LIKELY (CAMEL_IS_MIME_MESSAGE (containee))) 
    7070        { 
    7171                go = message_foreach_part_rec (msg, (CamelMimePart *)containee, callback, data); 
     
    9494destroy_part (gpointer data, gpointer user_data) 
    9595{ 
    96         if (data
     96        if (G_LIKELY (data)
    9797                g_object_unref (G_OBJECT (data)); 
    9898 
     
    105105        g_mutex_lock (priv->parts_lock); 
    106106 
    107         if (priv->parts)  
     107        if (G_LIKELY (priv->parts)) 
    108108        { 
    109109                g_list_foreach (priv->parts,  
     
    136136        g_mutex_lock (priv->message_lock); 
    137137 
    138         if (ppriv->part
     138        if (G_LIKELY (ppriv->part)
    139139                camel_object_unref (CAMEL_OBJECT (ppriv->part)); 
    140140 
     
    222222 
    223223        /* Warp it into a multipart */ 
    224         if (!containee || !CAMEL_IS_MULTIPART (containee)) 
     224        if (G_UNLIKELY (!containee) || G_LIKELY (!CAMEL_IS_MULTIPART (containee))) 
    225225        { 
    226226                /* TODO: restore original mime part? */ 
    227                 if (containee
     227                if (G_LIKELY (containee)
    228228                        camel_object_unref (CAMEL_OBJECT (containee)); 
    229229 
     
    274274        camel_multipart_remove_part_at (CAMEL_MULTIPART (containee), id); 
    275275 
    276         if (remove->data) 
    277                 camel_object_unref (CAMEL_OBJECT (remove->data)); 
    278         g_list_free (remove); 
    279  
     276        if (G_LIKELY (remove)) 
     277        { 
     278                if (G_LIKELY (remove->data)) 
     279                        camel_object_unref (CAMEL_OBJECT (remove->data)); 
     280 
     281                g_list_free (remove); 
     282        } 
    280283 
    281284        /* Warning: large lock that locks code, not data */ 
     
    302305        message = _tny_msg_header_get_camel_mime_message (TNY_MSG_HEADER (priv->header)); 
    303306 
    304         if (message
     307        if (G_UNLIKELY (message)
    305308                _tny_msg_set_camel_mime_message (TNY_MSG (self), message); 
    306309 
     
    318321 
    319322        g_mutex_lock (priv->header_lock); 
    320         if (priv->header
     323        if (G_LIKELY (priv->header)
    321324                g_object_unref (G_OBJECT (priv->header)); 
    322325        priv->header = NULL; 
     
    381384        gint nth=0; 
    382385 
    383         while (list
     386        while (G_LIKELY (list)
    384387        { 
    385388                if (TNY_IS_MSG_MIME_PART_IFACE (list->data)) 
     
    469472        static GType type = 0; 
    470473 
    471         if (!camel_type_init_done
     474        if (G_UNLIKELY (!camel_type_init_done)
    472475        { 
    473476                camel_type_init (); 
     
    475478        } 
    476479 
    477         if (type == 0)  
     480        if (G_UNLIKELY(type == 0)) 
    478481        { 
    479482                static const GTypeInfo info =  
  • trunk/libtinymail-camel/tny-session-camel.c

    r209 r212  
    432432{ 
    433433        /* TODO: potential problem: singleton without lock */ 
    434         if (!the_singleton
     434        if (G_UNLIKELY (!the_singleton)
    435435        { 
    436436                the_singleton = TNY_SESSION_CAMEL  
     
    484484        static CamelType tny_session_camel_type = CAMEL_INVALID_TYPE; 
    485485         
    486         if (!camel_type_init_done
     486        if (G_UNLIKELY (!camel_type_init_done)
    487487        { 
    488488                camel_type_init (); 
     
    490490        } 
    491491 
    492         if (tny_session_camel_type == CAMEL_INVALID_TYPE)  
     492        if (G_UNLIKELY (tny_session_camel_type == CAMEL_INVALID_TYPE))  
    493493        { 
    494494                ms_parent_class = (CamelSessionClass *)camel_session_get_type(); 
  • trunk/libtinymail-camel/tny-store-account.c

    r202 r212  
    6666                camel_url_set_host (url, priv->host); 
    6767         
    68                 if (priv->url_string
     68                if (G_LIKELY (priv->url_string)
    6969                        g_free (priv->url_string); 
    7070 
    7171                priv->url_string = camel_url_to_string (url, 0); 
    7272 
    73                 if (priv->service
     73                if (G_UNLIKELY (priv->service)
    7474                        camel_object_unref (CAMEL_OBJECT (priv->service)); 
    7575         
     
    7878                        priv->type, priv->ex); 
    7979         
    80                 if (priv->service == NULL) { 
     80                if (G_UNLIKELY (priv->service == NULL)) 
     81                { 
    8182                        g_error ("couldn't get service %s: %s\n", priv->url_string, 
    8283                                   camel_exception_get_description (priv->ex)); 
     
    8889        } 
    8990 
    90         if (priv->service && priv->pass_func_set && priv->proto && priv->user && priv->host) 
     91        if (G_LIKELY (priv->service) && G_UNLIKELY (priv->pass_func_set)  
     92                && G_UNLIKELY (priv->proto) && G_UNLIKELY (priv->user)  
     93                && G_UNLIKELY (priv->host)) 
    9194                camel_service_connect (priv->service, priv->ex); 
    9295 
     
    104107tny_store_account_clear_folders (TnyStoreAccountPriv *priv) 
    105108{ 
    106         if (priv->folders
     109        if (G_LIKELY (priv->folders)
    107110        { 
    108111                g_mutex_lock (priv->folders_lock); 
     
    111114        } 
    112115 
    113         if (priv->ufolders
     116        if (G_UNLIKELY (priv->ufolders)
    114117        { 
    115118                g_mutex_lock (priv->folders_lock); 
     
    139142                tny_msg_folder_iface_set_account (iface, TNY_ACCOUNT_IFACE (self)); 
    140143 
    141 &n