Changeset 12358


Ignore:
Timestamp:
Apr 13, 2011, 10:16:50 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) more heap pruning, in tr_core

Tweak how we loop through the torrents in the model, again to avoid unnecessary GtkTreePath? temporaries.

Location:
trunk/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r12349 r12358  
    14061406}
    14071407
    1408 static gboolean
    1409 update_foreach( GtkTreeModel * model,
    1410                 GtkTreePath  * path UNUSED,
    1411                 GtkTreeIter  * iter,
    1412                 gpointer       data UNUSED )
     1408static void
     1409update_foreach( GtkTreeModel * model, GtkTreeIter * iter )
    14131410{
    14141411    int oldActivity, newActivity;
     
    14791476                            -1 );
    14801477    }
    1481 
    1482     /* cleanup */
    1483     return FALSE;
    14841478}
    14851479
     
    14871481gtr_core_update( TrCore * core )
    14881482{
    1489     /* refresh the model */
    1490     gtk_tree_model_foreach( core_raw_model( core ), update_foreach, NULL );
    1491 
     1483    GtkTreeIter iter;
     1484    GtkTreeModel * model;
     1485
     1486    /* update the model */
     1487    model = core_raw_model( core );
     1488    if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
     1489        update_foreach( model, &iter );
     1490    while( gtk_tree_model_iter_next( model, &iter ) );
     1491
     1492    /* update hibernation */
    14921493    core_maybe_inhibit_hibernation( core );
    14931494}
     
    18511852    GtkTreeModel * model = core_raw_model( core );
    18521853
    1853     if( gtk_tree_model_get_iter_first( model, &iter ) ) do
     1854    if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
    18541855    {
    18551856        int activity;
  • trunk/gtk/tr-prefs.c

    r12223 r12358  
    615615refreshWhitelist( struct remote_page * page )
    616616{
    617     GtkTreeIter    iter;
     617    GtkTreeIter iter;
     618    GString * gstr = g_string_new( NULL );
    618619    GtkTreeModel * model = GTK_TREE_MODEL( page->store );
    619     GString *      gstr = g_string_new( NULL );
    620 
    621     if( gtk_tree_model_get_iter_first( model, &iter ) ) do
    622         {
    623             char * address;
    624             gtk_tree_model_get( model, &iter,
    625                                 COL_ADDRESS, &address,
    626                                 -1 );
    627             g_string_append( gstr, address );
    628             g_string_append( gstr, "," );
    629             g_free( address );
    630         }
    631         while( gtk_tree_model_iter_next( model, &iter ) );
     620
     621    if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
     622    {
     623        char * address;
     624        gtk_tree_model_get( model, &iter, COL_ADDRESS, &address, -1 );
     625        g_string_append( gstr, address );
     626        g_string_append( gstr, "," );
     627        g_free( address );
     628    }
     629    while( gtk_tree_model_iter_next( model, &iter ) );
    632630
    633631    g_string_truncate( gstr, gstr->len - 1 ); /* remove the trailing comma */
Note: See TracChangeset for help on using the changeset viewer.