mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
bitmask: Optimize intersect
The functions was written in a way that would possibly resize the mask twice, which is not necessary.
This commit is contained in:
parent
3a503b7ba1
commit
0957ba5220
@ -174,11 +174,14 @@ _gtk_allocated_bitmask_intersect (GtkBitmask *mask,
|
||||
mask = gtk_bitmask_ensure_allocated (mask);
|
||||
ENSURE_ALLOCATED (other, other_allocated);
|
||||
|
||||
mask = gtk_allocated_bitmask_resize (mask, MIN (mask->len, other->len));
|
||||
for (i = 0; i < mask->len; i++)
|
||||
for (i = 0; i < MIN (mask->len, other->len); i++)
|
||||
{
|
||||
mask->data[i] &= other->data[i];
|
||||
}
|
||||
for (; i < mask->len; i++)
|
||||
{
|
||||
mask->data[i] = 0;
|
||||
}
|
||||
|
||||
return gtk_allocated_bitmask_shrink (mask);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user