[evince] libview: Use GSlice to allocate EvViewSelection
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Use GSlice to allocate EvViewSelection
- Date: Fri, 21 Jun 2013 18:57:50 +0000 (UTC)
commit dc1e75b7be87a85859173c7f7f4560a44dc24855
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Fri Jun 21 20:53:00 2013 +0200
libview: Use GSlice to allocate EvViewSelection
These structs are allocated and deallocated a lot while selecting text
and merging selection regions.
libview/ev-pixbuf-cache.c | 6 +++---
libview/ev-view.c | 17 +++++++----------
2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 852baf5..865cee6 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -1195,7 +1195,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
}
if (pixbuf_cache->prev_job[i].selection_points.x1 != -1) {
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = page;
selection->rect = pixbuf_cache->prev_job[i].selection_points;
if (pixbuf_cache->prev_job[i].selection_region)
@@ -1209,7 +1209,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
page = pixbuf_cache->start_page;
for (i = 0; i < PAGE_CACHE_LEN (pixbuf_cache); i++) {
if (pixbuf_cache->job_list[i].selection_points.x1 != -1) {
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = page;
selection->rect = pixbuf_cache->job_list[i].selection_points;
if (pixbuf_cache->job_list[i].selection_region)
@@ -1225,7 +1225,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
break;
if (pixbuf_cache->next_job[i].selection_points.x1 != -1) {
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = page;
selection->rect = pixbuf_cache->next_job[i].selection_points;
if (pixbuf_cache->next_job[i].selection_region)
diff --git a/libview/ev-view.c b/libview/ev-view.c
index fb52d66..5bdc38f 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -7044,7 +7044,7 @@ compute_new_selection_rect (EvView *view,
if (gdk_rectangle_intersect (&page_area, &view_rect, &overlap)) {
EvViewSelection *selection;
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = i;
_ev_view_transform_view_rect_to_doc_rect (view, &overlap, &page_area,
&(selection->rect));
@@ -7122,7 +7122,7 @@ compute_new_selection_text (EvView *view,
get_doc_page_size (view, i, &width, &height);
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = i;
selection->style = style;
selection->rect.x1 = selection->rect.y1 = 0;
@@ -7175,8 +7175,7 @@ merge_selection_region (EvView *view,
/* Update the selection */
old_list = ev_pixbuf_cache_get_selection_list (view->pixbuf_cache);
- g_list_foreach (view->selection_info.selections, (GFunc)selection_free, NULL);
- g_list_free (view->selection_info.selections);
+ g_list_free_full (view->selection_info.selections, (GDestroyNotify)selection_free);
view->selection_info.selections = new_list;
ev_pixbuf_cache_set_selection_list (view->pixbuf_cache, new_list);
g_signal_emit (view, signals[SIGNAL_SELECTION_CHANGED], 0, NULL);
@@ -7304,8 +7303,7 @@ merge_selection_region (EvView *view,
}
/* Free the old list, now that we're done with it. */
- g_list_foreach (old_list, (GFunc) selection_free, NULL);
- g_list_free (old_list);
+ g_list_free_full (old_list, (GDestroyNotify)selection_free);
}
static void
@@ -7330,15 +7328,14 @@ selection_free (EvViewSelection *selection)
{
if (selection->covered_region)
cairo_region_destroy (selection->covered_region);
- g_free (selection);
+ g_slice_free (EvViewSelection, selection);
}
static void
clear_selection (EvView *view)
{
if (view->selection_info.selections) {
- g_list_foreach (view->selection_info.selections, (GFunc)selection_free, NULL);
- g_list_free (view->selection_info.selections);
+ g_list_free_full (view->selection_info.selections, (GDestroyNotify)selection_free);
view->selection_info.selections = NULL;
g_signal_emit (view, signals[SIGNAL_SELECTION_CHANGED], 0, NULL);
@@ -7367,7 +7364,7 @@ ev_view_select_all (EvView *view)
get_doc_page_size (view, i, &width, &height);
- selection = g_new0 (EvViewSelection, 1);
+ selection = g_slice_new0 (EvViewSelection);
selection->page = i;
selection->style = EV_SELECTION_STYLE_GLYPH;
selection->rect.x1 = selection->rect.y1 = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]