Use gint16 for GtkBorder

32K of border ought to be enough for any pixel dimensions. At least
until screens are so huge we start using doubles.

This saves a nice 64 bits of space when we have a GtkBorder
stored somewhere.

Signed integers are used to avoid surprising unsigned math
issues. Just search GTK's whole git log from inception
for "unsigned" if you want to find any number of commits
fixing signed/unsigned bugs.

https://bugzilla.gnome.org/show_bug.cgi?id=629387
This commit is contained in:
Havoc Pennington
2010-09-11 19:25:57 -04:00
parent 7e520d908a
commit b3079c0d18
2 changed files with 13 additions and 8 deletions

View File

@ -1941,6 +1941,7 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
GtkBorder border;
GScanner *scanner;
gboolean success = FALSE;
int left, right, top, bottom;
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
@ -1948,11 +1949,15 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
scanner = gtk_rc_scanner_new ();
g_scanner_input_text (scanner, gstring->str, gstring->len);
if (get_braced_int (scanner, TRUE, FALSE, &border.left) &&
get_braced_int (scanner, FALSE, FALSE, &border.right) &&
get_braced_int (scanner, FALSE, FALSE, &border.top) &&
get_braced_int (scanner, FALSE, TRUE, &border.bottom))
if (get_braced_int (scanner, TRUE, FALSE, &left) &&
get_braced_int (scanner, FALSE, FALSE, &right) &&
get_braced_int (scanner, FALSE, FALSE, &top) &&
get_braced_int (scanner, FALSE, TRUE, &bottom))
{
border.left = left;
border.right = right;
border.top = top;
border.bottom = bottom;
g_value_set_boxed (property_value, &border);
success = TRUE;
}

View File

@ -416,10 +416,10 @@ struct _GtkStyleClass
*/
struct _GtkBorder
{
gint left;
gint right;
gint top;
gint bottom;
gint16 left;
gint16 right;
gint16 top;
gint16 bottom;
};
GType gtk_style_get_type (void) G_GNUC_CONST;