diff options
author | Carlos Garcia Campos <[email protected]> | 2013-06-21 20:53:00 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-09-06 18:25:34 +0200 |
commit | ac8e6d76c49514be24ff6aa3e2db76b862483371 (patch) | |
tree | 7f28712bedd595669c36ececd283de59c37a90de /libview/ev-view.c | |
parent | 2a5caa32b6a98cf6a0e34c8f5ec79f94060932b3 (diff) | |
download | atril-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/ev-view.c')
-rw-r--r-- | libview/ev-view.c | 17 |
1 files changed, 7 insertions, 10 deletions
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; |