[gtk+] sizerequestcache: Make code an array
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] sizerequestcache: Make code an array
- Date: Wed, 14 Nov 2012 01:05:44 +0000 (UTC)
commit 43fc428cf0283e08725e3919ca599a73cc85557b
Author: Benjamin Otte <otte redhat com>
Date: Wed Nov 14 01:35:38 2012 +0100
sizerequestcache: Make code an array
We can use orientation as the index into an array. That way we can
delete half the code. Do it for the base request first in this patch.
gtk/gtksizerequestcache.c | 27 +++++----------------------
gtk/gtksizerequestcacheprivate.h | 8 ++++----
2 files changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtksizerequestcache.c b/gtk/gtksizerequestcache.c
index 3834520..0837620 100644
--- a/gtk/gtksizerequestcache.c
+++ b/gtk/gtksizerequestcache.c
@@ -72,18 +72,9 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
/* First handle caching of the base requests */
if (for_size < 0)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- cache->cached_width.minimum_size = minimum_size;
- cache->cached_width.natural_size = natural_size;
- cache->cached_base_width = TRUE;
- }
- else
- {
- cache->cached_height.minimum_size = minimum_size;
- cache->cached_height.natural_size = natural_size;
- cache->cached_base_height = TRUE;
- }
+ cache->cached_size[orientation].minimum_size = minimum_size;
+ cache->cached_size[orientation].natural_size = natural_size;
+ cache->flags[orientation].cached_size_valid = TRUE;
return;
}
@@ -182,16 +173,8 @@ _gtk_size_request_cache_lookup (SizeRequestCache *cache,
if (for_size < 0)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (cache->cached_base_width)
- result = &cache->cached_width;
- }
- else
- {
- if (cache->cached_base_height)
- result = &cache->cached_height;
- }
+ if (cache->flags[orientation].cached_size_valid)
+ result = &cache->cached_size[orientation];
}
else
{
diff --git a/gtk/gtksizerequestcacheprivate.h b/gtk/gtksizerequestcacheprivate.h
index 7c293d9..4ea05c3 100644
--- a/gtk/gtksizerequestcacheprivate.h
+++ b/gtk/gtksizerequestcacheprivate.h
@@ -54,8 +54,7 @@ typedef struct {
SizeRequest **widths;
SizeRequest **heights;
- CachedSize cached_width;
- CachedSize cached_height;
+ CachedSize cached_size[2];
GtkSizeRequestMode request_mode: 3;
guint request_mode_valid : 1;
@@ -63,8 +62,9 @@ typedef struct {
guint cached_heights : 3;
guint last_cached_width : 3;
guint last_cached_height : 3;
- guint cached_base_width : 1;
- guint cached_base_height : 1;
+ struct {
+ guint cached_size_valid : 1;
+ } flags[2];
} SizeRequestCache;
void _gtk_size_request_cache_init (SizeRequestCache *cache);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]