[gnumeric] Compilation: avoid memory allocation for no good reason.



commit 77ff691a3d87db4c7bea814e8febe530baeba6c0
Author: Morten Welinder <terra gnome org>
Date:   Thu May 26 14:17:14 2011 -0400

    Compilation: avoid memory allocation for no good reason.

 ChangeLog           |    5 +++++
 src/gui-clipboard.c |    7 ++-----
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d21c956..6a51db0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,6 +40,11 @@
 	* src/workbook.c (workbook_sheet_state_size): adjust scale
 	(cmd_reorganize_sheets): use workbook_sheet_state_size
 
+2011-05-26  Morten Welinder  <terra gnome org>
+
+	* src/gui-clipboard.c (table_cellregion_read): Avoid
+	workbook_sheets because it allocates needlessly.
+
 2011-05-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/parse-util.h (gnm_conventions_dup): new
diff --git a/src/gui-clipboard.c b/src/gui-clipboard.c
index 577b3ca..8ad866d 100644
--- a/src/gui-clipboard.c
+++ b/src/gui-clipboard.c
@@ -286,7 +286,6 @@ table_cellregion_read (WorkbookControl *wbc, char const *reader_id,
 {
 	WorkbookView *wb_view = NULL;
 	Workbook *wb = NULL;
-	GSList *sheets;
 	GnmCellRegion *ret = NULL;
 	const GOFileOpener *reader = go_file_opener_for_id (reader_id);
 	GOIOContext *ioc;
@@ -306,10 +305,9 @@ table_cellregion_read (WorkbookControl *wbc, char const *reader_id,
 	}
 
 	wb = wb_view_get_workbook (wb_view);
-	sheets = workbook_sheets (wb);
-	if (sheets) {
+	if (workbook_sheet_count (wb) > 0) {
 		GnmRange r;
-		Sheet *tmpsheet = sheets->data;
+		Sheet *tmpsheet = workbook_sheet_by_index (wb, 0);
 		GnmRange *rp = g_object_get_data (G_OBJECT (tmpsheet),
 						  "DIMENSION");
 		if (rp) {
@@ -322,7 +320,6 @@ table_cellregion_read (WorkbookControl *wbc, char const *reader_id,
 		}
 		ret = clipboard_copy_range (tmpsheet, &r);
 	}
-	g_slist_free (sheets);
 
 	/* This isn't particularly right, but we are going to delete
 	   the workbook shortly.  See #490479.  */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]