forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
70ba973d1d
commit
43fc428cf0
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user