[gtk+] bitmask: Optimize intersect
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] bitmask: Optimize intersect
- Date: Sat, 12 Sep 2015 17:05:42 +0000 (UTC)
commit 0957ba522008bc08631ee209b4dae8d7c5a7dce0
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 10 18:46:58 2015 -0400
bitmask: Optimize intersect
The functions was written in a way that would possibly
resize the mask twice, which is not necessary.
gtk/gtkallocatedbitmask.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkallocatedbitmask.c b/gtk/gtkallocatedbitmask.c
index 6f0f1f8..567b86c 100644
--- a/gtk/gtkallocatedbitmask.c
+++ b/gtk/gtkallocatedbitmask.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]