Hello, I browsed the Gnumeric's sources yesterday and grepped for 'TODO' in .c files. Anyway, in src/sheet.c I saw a lot of almost duplicate functions, one for column another for row. So I decided to start merging sheet_col_* and sheet_row_* into sheet_colrow_* functions.
This also has the size improving features (total 486 bytes less): gnumeric-1.5.1 6910604 -> 6910363 - 241 bytes ssconvert 6879933 -> 6879688 - 245 bytes I was just bored :P -- Priit Laes <amd tt ee> http://amd.store20.com
? sheet_colrow_add_cleanup.patch
? templates/autoformat/st
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnumeric/ChangeLog,v
retrieving revision 1.3832
diff -u -r1.3832 ChangeLog
--- ChangeLog 25 Mar 2005 03:23:26 -0000 1.3832
+++ ChangeLog 26 Mar 2005 10:09:02 -0000
@@ -1,3 +1,12 @@
+2005-03-25 Priit Laes <[EMAIL PROTECTED]>
+
+ * src/sheet.{c,h} (sheet_colrow_add): new function merged from
+ sheet_col_add and sheet_row_add.
+ (sheet_col_add), (sheet_row_add): removed.
+ (sheet_col_fetch), (sheet_row_fetch): use our new sheet_colrow_add.
+ * src/xml-io.c (xml_read_cols_info), (xml_read_rows_info): use our new
+ sheet_colrow_add.
+
2005-03-24 Andreas J. Guelzow <[EMAIL PROTECTED]>
* src/style-border.c (style_border_hash): use GPOINTER_TO_UINT
Index: src/sheet.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/sheet.c,v
retrieving revision 1.731
diff -u -r1.731 sheet.c
--- src/sheet.c 15 Mar 2005 14:46:52 -0000 1.731
+++ src/sheet.c 26 Mar 2005 10:09:04 -0000
@@ -611,45 +611,40 @@
}
void
-sheet_col_add (Sheet *sheet, ColRowInfo *cp)
+sheet_colrow_add (Sheet *sheet, ColRowInfo *p, gboolean is_cols)
{
- int const col = cp->pos;
- ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->cols), col);
-
- g_return_if_fail (col >= 0);
- g_return_if_fail (col < SHEET_MAX_COLS);
-
- if (*segment == NULL)
- *segment = g_new0 (ColRowSegment, 1);
- (*segment)->info[COLROW_SUB_INDEX (col)] = cp;
-
- if (cp->outline_level > sheet->cols.max_outline_level)
- sheet->cols.max_outline_level = cp->outline_level;
- if (col > sheet->cols.max_used) {
- sheet->cols.max_used = col;
- sheet->priv->resize_scrollbar = TRUE;
- }
-}
-
-void
-sheet_row_add (Sheet *sheet, ColRowInfo *rp)
-{
- int const row = rp->pos;
- ColRowSegment **segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->rows), row);
-
- g_return_if_fail (row >= 0);
- g_return_if_fail (row < SHEET_MAX_ROWS);
-
- if (*segment == NULL)
- *segment = g_new0 (ColRowSegment, 1);
- (*segment)->info[COLROW_SUB_INDEX (row)] = rp;
-
- if (rp->outline_level > sheet->rows.max_outline_level)
- sheet->rows.max_outline_level = rp->outline_level;
- if (row > sheet->rows.max_used) {
- sheet->rows.max_used = row;
- sheet->priv->resize_scrollbar = TRUE;
- }
+ int const colrow = p->pos;
+ ColRowSegment **segment;
+ if (is_cols)
+ segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->cols), colrow);
+ else
+ segment = (ColRowSegment **)&COLROW_GET_SEGMENT (&(sheet->rows), colrow);
+
+ g_return_if_fail (colrow >= 0);
+ if (is_cols)
+ g_return_if_fail (colrow < SHEET_MAX_COLS);
+ else
+ g_return_if_fail (colrow < SHEET_MAX_ROWS);
+
+ if (*segment == NULL)
+ *segment = g_new0 (ColRowSegment, 1);
+ (*segment)->info[COLROW_SUB_INDEX (colrow)] = p;
+
+ if (is_cols) {
+ if (p->outline_level > sheet->cols.max_outline_level)
+ sheet->cols.max_outline_level = p->outline_level;
+ if (colrow > sheet->cols.max_used) {
+ sheet->cols.max_used = colrow;
+ sheet->priv->resize_scrollbar = TRUE;
+ }
+ } else {
+ if (p->outline_level > sheet->rows.max_outline_level)
+ sheet->rows.max_outline_level = p->outline_level;
+ if (colrow > sheet->rows.max_used) {
+ sheet->rows.max_used = colrow;
+ sheet->priv->resize_scrollbar = TRUE;
+ }
+ }
}
static void
@@ -2228,7 +2223,7 @@
if (res == NULL)
if ((res = sheet_col_new (sheet)) != NULL) {
res->pos = pos;
- sheet_col_add (sheet, res);
+ sheet_colrow_add (sheet, res, TRUE);
}
return res;
}
@@ -2245,7 +2240,7 @@
if (res == NULL)
if ((res = sheet_row_new (sheet)) != NULL) {
res->pos = pos;
- sheet_row_add (sheet, res);
+ sheet_colrow_add (sheet, res, FALSE);
}
return res;
}
@@ -3131,11 +3126,7 @@
segment->info [COLROW_SUB_INDEX (old_pos)] = NULL;
info->pos = new_pos;
- /* TODO : Figure out a way to merge these functions */
- if (is_cols)
- sheet_col_add (sheet, info);
- else
- sheet_row_add (sheet, info);
+ sheet_colrow_add (sheet, info, is_cols);
/* Insert the cells back */
for (; cells != NULL ; cells = g_list_remove (cells, cell)) {
Index: src/sheet.h
===================================================================
RCS file: /cvs/gnome/gnumeric/src/sheet.h,v
retrieving revision 1.349
diff -u -r1.349 sheet.h
--- src/sheet.h 15 Mar 2005 14:46:52 -0000 1.349
+++ src/sheet.h 26 Mar 2005 10:09:05 -0000
@@ -156,8 +156,7 @@
int colrow, gboolean is_cols);
/* Add a ColRowInfo to the Sheet */
-void sheet_col_add (Sheet *sheet, ColRowInfo *cp);
-void sheet_row_add (Sheet *sheet, ColRowInfo *cp);
+void sheet_colrow_add (Sheet *sheet, ColRowInfo *cp, gboolean is_cols);
/*
* Definitions of row/col size terminology :
Index: src/xml-io.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/xml-io.c,v
retrieving revision 1.448
diff -u -r1.448 xml-io.c
--- src/xml-io.c 17 Mar 2005 19:07:51 -0000 1.448
+++ src/xml-io.c 26 Mar 2005 10:09:06 -0000
@@ -2911,7 +2911,7 @@
if (!xmlIsBlankNode (col)) {
info = sheet_col_new (sheet);
count = xml_read_colrow_info (ctxt, col, info, &size_pts);
- sheet_col_add (sheet, info);
+ sheet_colrow_add (sheet, info, TRUE);
sheet_col_set_size_pts (ctxt->sheet, info->pos, size_pts, info->hard_size);
/* resize flags are already set only need to copy the sizes */
@@ -2940,7 +2940,7 @@
if (!xmlIsBlankNode (row)) {
info = sheet_row_new (sheet);
count = xml_read_colrow_info (ctxt, row, info, &size_pts);
- sheet_row_add (sheet, info);
+ sheet_colrow_add (sheet, info, FALSE);
sheet_row_set_size_pts (ctxt->sheet, info->pos, size_pts, info->hard_size);
/* resize flags are already set only need to copy the sizes */
signature.asc
Description: This is a digitally signed message part
_______________________________________________ gnumeric-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnumeric-list
