[evolution-mapi] Prefer GSlice over heap allocation for short-lived structures
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Prefer GSlice over heap allocation for short-lived structures
- Date: Wed, 22 Jan 2020 09:10:57 +0000 (UTC)
commit 7204200be57c8758f1920b1ecd6da17eef56a8bc
Author: Milan Crha <mcrha redhat com>
Date: Wed Jan 22 10:13:05 2020 +0100
Prefer GSlice over heap allocation for short-lived structures
It might be quicker to use GSlice than to allocate new memory on the heap,
thus let's try to benefit from it.
src/camel/camel-mapi-store.c | 8 ++++----
src/collection/e-mapi-backend.c | 6 +++---
src/configuration/e-mail-config-mapi-backend.c | 4 ++--
src/configuration/e-mapi-config-utils.c | 14 +++++++-------
src/configuration/e-mapi-search-gal-user.c | 8 ++++----
src/configuration/e-mapi-subscribe-foreign-folder.c | 4 ++--
6 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 38f8cc8..622a098 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -2368,7 +2368,7 @@ free_schedule_update_data (gpointer ptr)
if (sud->cancellable)
g_object_unref (sud->cancellable);
g_slist_free_full (sud->foldernames, g_free);
- g_free (sud);
+ g_slice_free (struct ScheduleUpdateData, sud);
}
static gpointer
@@ -2418,7 +2418,7 @@ run_update_thread (CamelMapiStore *mapi_store,
g_return_if_fail (mapi_store != NULL);
g_return_if_fail (cancellable != NULL);
- sud = g_new0 (struct ScheduleUpdateData, 1);
+ sud = g_slice_new0 (struct ScheduleUpdateData);
sud->mapi_store = mapi_store;
sud->cancellable = g_object_ref (cancellable);
sud->foldernames = foldernames;
@@ -2502,7 +2502,7 @@ schedule_folder_update (CamelMapiStore *mapi_store, mapi_id_t fid)
return;
}
- sud = g_new0 (struct ScheduleUpdateData, 1);
+ sud = g_slice_new0 (struct ScheduleUpdateData);
sud->cancellable = g_object_ref (mapi_store->priv->updates_cancellable);
sud->mapi_store = mapi_store;
@@ -2559,7 +2559,7 @@ schedule_folder_list_update (CamelMapiStore *mapi_store)
return;
}
- sud = g_new0 (struct ScheduleUpdateData, 1);
+ sud = g_slice_new0 (struct ScheduleUpdateData);
sud->cancellable = g_object_ref (mapi_store->priv->updates_cancellable);
sud->mapi_store = mapi_store;
diff --git a/src/collection/e-mapi-backend.c b/src/collection/e-mapi-backend.c
index ca29988..3b6f4b1 100644
--- a/src/collection/e-mapi-backend.c
+++ b/src/collection/e-mapi-backend.c
@@ -143,7 +143,7 @@ sync_folders_data_free (gpointer data)
e_mapi_folder_free_list (sfd->folders);
g_object_unref (sfd->backend);
g_free (sfd->profile);
- g_free (sfd);
+ g_slice_free (struct SyndFoldersData, sfd);
}
static void
@@ -404,7 +404,7 @@ mapi_backend_queue_auth_session (EMapiBackend *backend)
if (!e_backend_get_online (E_BACKEND (backend))) {
struct SyndFoldersData *sfd;
- sfd = g_new0 (struct SyndFoldersData, 1);
+ sfd = g_slice_new0 (struct SyndFoldersData);
sfd->folders = NULL;
sfd->backend = g_object_ref (backend);
sfd->profile = camel_mapi_settings_dup_profile (mapi_settings);
@@ -918,7 +918,7 @@ mapi_backend_authenticate_sync (EBackend *backend,
mapi_backend->priv->credentials = credentials ? e_named_parameters_new_clone (credentials) :
NULL;
g_mutex_unlock (&mapi_backend->priv->credentials_lock);
- sfd = g_new0 (struct SyndFoldersData, 1);
+ sfd = g_slice_new0 (struct SyndFoldersData);
sfd->folders = mapi_folders;
sfd->backend = g_object_ref (mapi_backend);
sfd->profile = camel_mapi_settings_dup_profile (settings);
diff --git a/src/configuration/e-mail-config-mapi-backend.c b/src/configuration/e-mail-config-mapi-backend.c
index 4a02893..ba09041 100644
--- a/src/configuration/e-mail-config-mapi-backend.c
+++ b/src/configuration/e-mail-config-mapi-backend.c
@@ -287,7 +287,7 @@ try_credentials_data_free (gpointer ptr)
g_free (data->krb_realm);
g_object_unref (data->mapi_settings);
g_object_unref (data->backend);
- g_free (data);
+ g_slice_free (TryCredentialsData, data);
}
}
@@ -476,7 +476,7 @@ validate_credentials_cb (GtkWidget *widget,
}
if (COMPLETE_PROFILEDATA (&empd)) {
- TryCredentialsData *data = g_new0 (TryCredentialsData, 1);
+ TryCredentialsData *data = g_slice_new0 (TryCredentialsData);
data->username = g_strdup (empd.username);
data->domain = g_strdup (empd.domain);
diff --git a/src/configuration/e-mapi-config-utils.c b/src/configuration/e-mapi-config-utils.c
index aa5a725..4beb1bf 100644
--- a/src/configuration/e-mapi-config-utils.c
+++ b/src/configuration/e-mapi-config-utils.c
@@ -80,7 +80,7 @@ free_run_with_feedback_data (gpointer ptr)
g_clear_error (&rfd->error);
- g_free (rfd);
+ g_slice_free (struct RunWithFeedbackData, rfd);
}
static gboolean
@@ -184,7 +184,7 @@ e_mapi_config_utils_run_in_thread_with_feedback_general (GtkWindow *parent,
gtk_container_add (GTK_CONTAINER (content), box);
gtk_container_set_border_width (GTK_CONTAINER (content), 12);
- rfd = g_new0 (struct RunWithFeedbackData, 1);
+ rfd = g_slice_new0 (struct RunWithFeedbackData);
rfd->parent = parent;
rfd->dialog = dialog;
rfd->cancellable = g_cancellable_new ();
@@ -477,7 +477,7 @@ mapi_settings_get_folder_size_idle (gpointer user_data)
g_object_unref (fsd->mapi_settings);
g_object_unref (fsd->cancellable);
g_clear_error (&fsd->error);
- g_free (fsd);
+ g_slice_free (FolderSizeDialogData, fsd);
return FALSE;
}
@@ -533,7 +533,7 @@ e_mapi_config_utils_run_folder_size_dialog (ESourceRegistry *registry,
GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
NULL);
- fsd = g_new0 (FolderSizeDialogData, 1);
+ fsd = g_slice_new0 (FolderSizeDialogData);
fsd->dialog = GTK_DIALOG (dialog);
gtk_window_set_default_size (GTK_WINDOW (fsd->dialog), 250, 300);
@@ -1615,7 +1615,7 @@ e_mapi_folder_structure_data_free (gpointer ptr)
g_object_unref (fsd->config);
g_object_unref (fsd->child_source);
g_object_unref (fsd->registry);
- g_free (fsd);
+ g_slice_free (struct EMapiFolderStructureData, fsd);
}
static void
@@ -1711,7 +1711,7 @@ tree_view_mapped_cb (GObject *tree_view)
g_return_if_fail (parent_source != NULL);
- fsd = g_new0 (struct EMapiFolderStructureData, 1);
+ fsd = g_slice_new0 (struct EMapiFolderStructureData);
fsd->folder_type = old_fsd->folder_type;
fsd->folders = NULL;
fsd->tree_view = g_object_ref (old_fsd->tree_view);
@@ -1857,7 +1857,7 @@ e_mapi_config_utils_insert_widgets (ESourceConfigBackend *backend,
if (e_mapi_config_utils_is_online ()) {
struct EMapiFolderStructureData *fsd;
- fsd = g_new0 (struct EMapiFolderStructureData, 1);
+ fsd = g_slice_new0 (struct EMapiFolderStructureData);
fsd->folder_type = folder_type;
fsd->folders = NULL;
fsd->tree_view = g_object_ref (tree_view);
diff --git a/src/configuration/e-mapi-search-gal-user.c b/src/configuration/e-mapi-search-gal-user.c
index ff31d9f..0aefb9c 100644
--- a/src/configuration/e-mapi-search-gal-user.c
+++ b/src/configuration/e-mapi-search-gal-user.c
@@ -71,7 +71,7 @@ e_mapi_search_gal_user_data_free (gpointer ptr)
}
g_object_unref (pgu->conn);
g_free (pgu->search_text);
- g_free (pgu);
+ g_slice_free (struct EMapiSearchGalUserData, pgu);
}
struct EMapiGalSearchUser
@@ -122,7 +122,7 @@ e_mapi_search_idle_data_free (gpointer ptr)
g_object_unref (sid->cancellable);
g_free (sid->search_text);
g_slist_free_full (sid->found_users, e_mapi_search_gal_user_free);
- g_free (sid);
+ g_slice_free (struct EMapiSearchIdleData, sid);
}
static void
@@ -526,7 +526,7 @@ search_term_changed_cb (GtkEntry *entry,
} else {
struct EMapiSearchIdleData *sid;
- sid = g_new0 (struct EMapiSearchIdleData, 1);
+ sid = g_slice_new0 (struct EMapiSearchIdleData);
sid->cancellable = g_object_ref (pgu->cancellable);
sid->dialog = dialog;
@@ -639,7 +639,7 @@ e_mapi_search_gal_user_modal (GtkWindow *parent,
g_return_val_if_fail (searched_type != NULL, FALSE);
g_return_val_if_fail (display_name || email || entry_id || user_dn, FALSE);
- pgu = g_new0 (struct EMapiSearchGalUserData, 1);
+ pgu = g_slice_new0 (struct EMapiSearchGalUserData);
pgu->conn = g_object_ref (conn);
pgu->search_extra = 0; /* always none, as default/anonymous user cannot be added to permissions */
diff --git a/src/configuration/e-mapi-subscribe-foreign-folder.c
b/src/configuration/e-mapi-subscribe-foreign-folder.c
index 6dfe5d4..19c5741 100644
--- a/src/configuration/e-mapi-subscribe-foreign-folder.c
+++ b/src/configuration/e-mapi-subscribe-foreign-folder.c
@@ -245,7 +245,7 @@ e_mapi_check_foreign_folder_data_free (gpointer ptr)
if (cffd->folder_id && cffd->dialog)
gtk_widget_destroy (cffd->dialog);
- g_free (cffd);
+ g_slice_free (struct EMapiCheckForeignFolderData, cffd);
}
static gboolean
@@ -577,7 +577,7 @@ subscribe_foreign_response_cb (GObject *dialog,
use_foldername = g_strdup ("Tasks");
}
- cffd = g_new0 (struct EMapiCheckForeignFolderData, 1);
+ cffd = g_slice_new0 (struct EMapiCheckForeignFolderData);
cffd->dialog = GTK_WIDGET (dialog);
cffd->username = g_strdup (username ? username : "");
cffd->direct_username = g_strdup (g_object_get_data (G_OBJECT (entry), STR_MAPI_DIRECT_USER_NAME));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]