[gnumeric] Sheet Objects: minor optimizations.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Sheet Objects: minor optimizations.
- Date: Fri, 5 Jun 2020 01:16:43 +0000 (UTC)
commit 714da549d44476aedb619dd177a1336fac139da7
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 4 21:15:39 2020 -0400
Sheet Objects: minor optimizations.
This should improve the many-objects situation a bit, both for build
and teardown.
ChangeLog | 8 ++++++++
src/sheet-filter.c | 2 +-
src/sheet-object.c | 22 +++++++++++-----------
src/sheet-object.h | 2 +-
4 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ed7a77a06..4953152d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-06-04 Morten Welinder <terra gnome org>
+
+ * src/sheet-filter.c (gnm_filter_remove): Remove fields in
+ opposite order of how we add them.
+
+ * src/sheet-object.c (sheet_object_set_sheet): Drop return value
+ that nobody looks at.
+
2020-06-04 Morten Welinder <terra gnome org>
* src/sheet-private.h (_SheetPrivate): Add objects_changed flag
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index f34c0cedc..ff42f24c0 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -796,7 +796,7 @@ gnm_filter_remove (GnmFilter *filter)
}
filter->sheet = NULL;
- for (i = 0 ; i < (int)filter->fields->len ; i++) {
+ for (i = filter->fields->len; i-- > 0; ) {
SheetObject *so = g_ptr_array_index (filter->fields, i);
sheet_object_clear_sheet (so);
g_object_unref (so);
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 19c005587..54a4ed087 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -45,6 +45,8 @@
#include <string.h>
+static gboolean debug_sheet_objects;
+
static guint so_create_view_src;
static GPtrArray *so_create_view_sos;
@@ -560,26 +562,25 @@ cb_create_views (void)
* @sheet:
*
* Adds a reference to the object.
- *
- * Returns: %TRUE if there was a problem
**/
-gboolean
+void
sheet_object_set_sheet (SheetObject *so, Sheet *sheet)
{
- g_return_val_if_fail (GNM_IS_SO (so), TRUE);
- g_return_val_if_fail (IS_SHEET (sheet), TRUE);
+ g_return_if_fail (GNM_IS_SO (so));
+ g_return_if_fail (IS_SHEET (sheet));
if (sheet == so->sheet)
- return FALSE;
+ return;
- g_return_val_if_fail (so->sheet == NULL, TRUE);
- g_return_val_if_fail (g_slist_find (sheet->sheet_objects, so) == NULL, TRUE);
+ g_return_if_fail (so->sheet == NULL);
+ if (debug_sheet_objects)
+ g_return_if_fail (g_slist_find (sheet->sheet_objects, so) == NULL);
so->sheet = sheet;
if (SO_CLASS (so)->assign_to_sheet &&
SO_CLASS (so)->assign_to_sheet (so, sheet)) {
so->sheet = NULL;
- return TRUE;
+ return;
}
g_object_ref (so);
@@ -603,8 +604,6 @@ sheet_object_set_sheet (SheetObject *so, Sheet *sheet)
NULL,
NULL);
}
-
- return FALSE;
}
/**
@@ -1927,6 +1926,7 @@ sheet_object_move_do (GSList *objects, GSList *anchors,
void
sheet_objects_init (void)
{
+ debug_sheet_objects = gnm_debug_flag ("sheet-objects");
so_create_view_sos = g_ptr_array_new ();
GNM_SO_LINE_TYPE;
diff --git a/src/sheet-object.h b/src/sheet-object.h
index 9af17a334..00fb600e0 100644
--- a/src/sheet-object.h
+++ b/src/sheet-object.h
@@ -49,7 +49,7 @@ GType sheet_object_imageable_get_type (void);
GType sheet_object_exportable_get_type (void);
-gboolean sheet_object_set_sheet (SheetObject *so, Sheet *sheet);
+void sheet_object_set_sheet (SheetObject *so, Sheet *sheet);
Sheet *sheet_object_get_sheet (SheetObject const *so);
void sheet_object_clear_sheet (SheetObject *so);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]