mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
(trunk gtk) more heap pruning, in tr_core
Tweak how we loop through the torrents in the model, again to avoid unnecessary GtkTreePath temporaries.
This commit is contained in:
parent
6cd1dcb574
commit
fdbe7dc2da
2 changed files with 23 additions and 24 deletions
|
@ -1405,11 +1405,8 @@ gtr_compare_double( const double a, const double b, int decimal_places )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
update_foreach( GtkTreeModel * model,
|
update_foreach( GtkTreeModel * model, GtkTreeIter * iter )
|
||||||
GtkTreePath * path UNUSED,
|
|
||||||
GtkTreeIter * iter,
|
|
||||||
gpointer data UNUSED )
|
|
||||||
{
|
{
|
||||||
int oldActivity, newActivity;
|
int oldActivity, newActivity;
|
||||||
int oldActivePeerCount, newActivePeerCount;
|
int oldActivePeerCount, newActivePeerCount;
|
||||||
|
@ -1478,17 +1475,21 @@ update_foreach( GtkTreeModel * model,
|
||||||
MC_RECHECK_PROGRESS, newRecheckProgress,
|
MC_RECHECK_PROGRESS, newRecheckProgress,
|
||||||
-1 );
|
-1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtr_core_update( TrCore * core )
|
gtr_core_update( TrCore * core )
|
||||||
{
|
{
|
||||||
/* refresh the model */
|
GtkTreeIter iter;
|
||||||
gtk_tree_model_foreach( core_raw_model( core ), update_foreach, NULL );
|
GtkTreeModel * model;
|
||||||
|
|
||||||
|
/* update the model */
|
||||||
|
model = core_raw_model( core );
|
||||||
|
if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
|
||||||
|
update_foreach( model, &iter );
|
||||||
|
while( gtk_tree_model_iter_next( model, &iter ) );
|
||||||
|
|
||||||
|
/* update hibernation */
|
||||||
core_maybe_inhibit_hibernation( core );
|
core_maybe_inhibit_hibernation( core );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1850,7 +1851,7 @@ gtr_core_get_active_torrent_count( TrCore * core )
|
||||||
size_t activeCount = 0;
|
size_t activeCount = 0;
|
||||||
GtkTreeModel * model = core_raw_model( core );
|
GtkTreeModel * model = core_raw_model( core );
|
||||||
|
|
||||||
if( gtk_tree_model_get_iter_first( model, &iter ) ) do
|
if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
|
||||||
{
|
{
|
||||||
int activity;
|
int activity;
|
||||||
gtk_tree_model_get( model, &iter, MC_ACTIVITY, &activity, -1 );
|
gtk_tree_model_get( model, &iter, MC_ACTIVITY, &activity, -1 );
|
||||||
|
|
|
@ -614,21 +614,19 @@ struct remote_page
|
||||||
static void
|
static void
|
||||||
refreshWhitelist( struct remote_page * page )
|
refreshWhitelist( struct remote_page * page )
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
GString * gstr = g_string_new( NULL );
|
||||||
GtkTreeModel * model = GTK_TREE_MODEL( page->store );
|
GtkTreeModel * model = GTK_TREE_MODEL( page->store );
|
||||||
GString * gstr = g_string_new( NULL );
|
|
||||||
|
|
||||||
if( gtk_tree_model_get_iter_first( model, &iter ) ) do
|
if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
|
||||||
{
|
{
|
||||||
char * address;
|
char * address;
|
||||||
gtk_tree_model_get( model, &iter,
|
gtk_tree_model_get( model, &iter, COL_ADDRESS, &address, -1 );
|
||||||
COL_ADDRESS, &address,
|
g_string_append( gstr, address );
|
||||||
-1 );
|
g_string_append( gstr, "," );
|
||||||
g_string_append( gstr, address );
|
g_free( address );
|
||||||
g_string_append( gstr, "," );
|
}
|
||||||
g_free( address );
|
while( gtk_tree_model_iter_next( model, &iter ) );
|
||||||
}
|
|
||||||
while( gtk_tree_model_iter_next( model, &iter ) );
|
|
||||||
|
|
||||||
g_string_truncate( gstr, gstr->len - 1 ); /* remove the trailing comma */
|
g_string_truncate( gstr, gstr->len - 1 ); /* remove the trailing comma */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue