summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2013-06-21 20:53:00 +0200
committerraveit65 <[email protected]>2017-09-06 18:25:34 +0200
commitac8e6d76c49514be24ff6aa3e2db76b862483371 (patch)
tree7f28712bedd595669c36ececd283de59c37a90de /libview
parent2a5caa32b6a98cf6a0e34c8f5ec79f94060932b3 (diff)
downloadatril-ac8e6d76c49514be24ff6aa3e2db76b862483371.tar.bz2
atril-ac8e6d76c49514be24ff6aa3e2db76b862483371.tar.xz
libview: Use GSlice to allocate EvViewSelection
These structs are allocated and deallocated a lot while selecting text and merging selection regions. orign commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=dc1e75b7be87
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-pixbuf-cache.c6
-rw-r--r--libview/ev-view.c17
2 files changed, 10 insertions, 13 deletions
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 542775d0..89225d08 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -1231,7 +1231,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)
@@ -1245,7 +1245,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)
@@ -1261,7 +1261,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 801dfda3..0c452237 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -7357,7 +7357,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));
@@ -7435,7 +7435,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;
@@ -7489,8 +7489,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);
@@ -7607,8 +7606,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
@@ -7633,15 +7631,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);
@@ -7670,7 +7667,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;