gnumeric r16837 - in trunk: . src



Author: mortenw
Date: Wed Oct  1 18:03:18 2008
New Revision: 16837
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16837&view=rev

Log:
Cleanup.



Modified:
   trunk/ChangeLog
   trunk/src/colrow.c
   trunk/src/colrow.h

Modified: trunk/src/colrow.c
==============================================================================
--- trunk/src/colrow.c	(original)
+++ trunk/src/colrow.c	Wed Oct  1 18:03:18 2008
@@ -304,20 +304,17 @@
 	return list;
 }
 
-ColRowStateList	*
-colrow_make_state (G_GNUC_UNUSED Sheet *sheet, int count,
-		   float size_pts, gboolean hard_size,
-		   int outline_level)
-{
-	ColRowRLEState  *rles = g_new0 (ColRowRLEState, 1);
-	rles->length = count;
-	rles->state.size_pts	  = size_pts;
-	rles->state.outline_level = outline_level;
-	rles->state.is_collapsed  = FALSE;
-	rles->state.hard_size	  = hard_size;
-	rles->state.visible	  = TRUE;
-	rles->state.is_default	  = FALSE;
-	return g_slist_prepend (NULL, rles);
+static void
+colrow_set_single_state (ColRowState *state,
+			 Sheet *sheet, int i, gboolean is_cols)
+{
+	ColRowInfo const *info = sheet_colrow_get_info (sheet, i, is_cols);
+	state->is_default = colrow_is_default (info);
+	state->size_pts	= info->size_pts;
+	state->outline_level = info->outline_level;
+	state->is_collapsed = info->is_collapsed;
+	state->hard_size = info->hard_size;
+	state->visible = info->visible;
 }
 
 ColRowStateList *
@@ -325,29 +322,18 @@
 {
 	ColRowStateList *list = NULL;
 	ColRowRLEState  *rles;
-	/* gcc is wrong run_state is always initialized */
-	ColRowState	 run_state, cur_state;
-	int              i, run_length = 0;
+	ColRowState	 run_state;
+	int              i, run_length;
 
 	g_return_val_if_fail (IS_SHEET (sheet), NULL);
 	g_return_val_if_fail (first <= last, NULL);
 
-	for (i = first; i <= last; ++i) {
-		ColRowInfo const *info = sheet_colrow_get_info (sheet, i, is_cols);
+	colrow_set_single_state (&run_state, sheet, first, is_cols);
+	run_length = 1;
 
-		cur_state.is_default	= colrow_is_default (info);
-		cur_state.size_pts	= info->size_pts;
-		cur_state.outline_level = info->outline_level;
-		cur_state.is_collapsed	= info->is_collapsed;
-		cur_state.hard_size	= info->hard_size;
-		cur_state.visible	= info->visible;
-
-		/* Initialize the run_size in the first loop */
-		if (run_length == 0) {
-			run_state = cur_state;
-			run_length = 1;
-			continue;
-		}
+	for (i = first + 1; i <= last; ++i) {
+		ColRowState cur_state;
+		colrow_set_single_state (&cur_state, sheet, i, is_cols);
 
 		/* If state changed, start a new block */
 		if (cur_state.is_default    != run_state.is_default ||
@@ -356,7 +342,7 @@
 		    cur_state.is_collapsed  != run_state.is_collapsed ||
 		    cur_state.hard_size	    != run_state.hard_size ||
 		    cur_state.visible	    != run_state.visible) {
-			rles         = g_new0 (ColRowRLEState, 1);
+			rles = g_new (ColRowRLEState, 1);
 			rles->length = run_length;
 			rles->state  = run_state;
 			list = g_slist_prepend (list, rles);
@@ -368,12 +354,10 @@
 	}
 
 	/* Store the final run */
-	if (run_length > 0) {
-		rles         = g_new0 (ColRowRLEState, 1);
-		rles->length = run_length;
-		rles->state  = run_state;
-		list = g_slist_prepend (list, rles);
-	}
+	rles = g_new (ColRowRLEState, 1);
+	rles->length = run_length;
+	rles->state = run_state;
+	list = g_slist_prepend (list, rles);
 
 	return g_slist_reverse (list);
 }

Modified: trunk/src/colrow.h
==============================================================================
--- trunk/src/colrow.h	(original)
+++ trunk/src/colrow.h	Wed Oct  1 18:03:18 2008
@@ -97,9 +97,7 @@
 					      ColRowIndexList *list);
 
 ColRowStateList	*colrow_state_list_destroy   (ColRowStateList *list);
-ColRowStateList	*colrow_make_state	     (Sheet *sheet, int count,
-					      float size_pts, gboolean hard_size,
-					      int outline_level);
+
 ColRowStateList	*colrow_get_states	     (Sheet *sheet, gboolean is_cols,
 					      int first, int last);
 void		 colrow_set_states	     (Sheet *sheet, gboolean is_cols,



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