[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59575] trunk/blender/source/blender/bmesh /intern: internal bmesh operator change, always initialize ghash for mapping slots, save having many checks.
Campbell Barton
ideasman42 at gmail.com
Wed Aug 28 00:13:11 CEST 2013
Revision: 59575
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59575
Author: campbellbarton
Date: 2013-08-27 22:13:11 +0000 (Tue, 27 Aug 2013)
Log Message:
-----------
internal bmesh operator change, always initialize ghash for mapping slots, save having many checks.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h 2013-08-27 21:30:33 UTC (rev 59574)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h 2013-08-27 22:13:11 UTC (rev 59575)
@@ -123,12 +123,6 @@
BLI_INLINE bool BMO_slot_map_contains(BMOpSlot *slot, const void *element)
{
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
-
- /* sanity check */
- if (UNLIKELY(slot->data.ghash == NULL)) {
- return false;
- }
-
return BLI_ghash_haskey(slot->data.ghash, element);
}
@@ -137,11 +131,6 @@
BMOElemMapping *mapping;
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
- /* sanity check */
- if (UNLIKELY(slot->data.ghash == NULL)) {
- return NULL;
- }
-
mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
if (!mapping) {
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.c 2013-08-27 21:30:33 UTC (rev 59574)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.c 2013-08-27 22:13:11 UTC (rev 59575)
@@ -127,15 +127,41 @@
/* use for both slot_types_in and slot_types_out */
static void bmo_op_slots_init(const BMOSlotType *slot_types, BMOpSlot *slot_args)
{
+ BMOpSlot *slot;
unsigned int i;
for (i = 0; slot_types[i].type; i++) {
- slot_args[i].slot_name = slot_types[i].name;
- slot_args[i].slot_type = slot_types[i].type;
- slot_args[i].slot_subtype = slot_types[i].subtype;
- // slot_args[i].index = i; // UNUSED
+ slot = &slot_args[i];
+ slot->slot_name = slot_types[i].name;
+ slot->slot_type = slot_types[i].type;
+ slot->slot_subtype = slot_types[i].subtype;
+ // slot->index = i; // UNUSED
+
+ switch (slot->slot_type) {
+ case BMO_OP_SLOT_MAPPING:
+ slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
+ break;
+ default:
+ break;
+ }
}
}
+static void bmo_op_slots_free(const BMOSlotType *slot_types, BMOpSlot *slot_args)
+{
+ BMOpSlot *slot;
+ unsigned int i;
+ for (i = 0; slot_types[i].type; i++) {
+ slot = &slot_args[i];
+ switch (slot->slot_type) {
+ case BMO_OP_SLOT_MAPPING:
+ BLI_ghash_free(slot->data.ghash, NULL, NULL);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
/**
* \brief BMESH OPSTACK INIT OP
*
@@ -198,20 +224,6 @@
BMO_pop(bm);
}
-static void bmo_op_slots_free(const BMOSlotType *slot_types, BMOpSlot *slot_args)
-{
- BMOpSlot *slot;
- unsigned int i;
- for (i = 0; slot_types[i].type; i++) {
- slot = &slot_args[i];
- if (slot->slot_type == BMO_OP_SLOT_MAPPING) {
- if (slot->data.ghash) {
- BLI_ghash_free(slot->data.ghash, NULL, NULL);
- }
- }
- }
-}
-
/**
* \brief BMESH OPSTACK FINISH OP
*
@@ -335,15 +347,6 @@
GHashIterator it;
BMOElemMapping *srcmap, *dstmap;
- /* sanity check */
- if (!slot_src->data.ghash) {
- return;
- }
-
- if (!slot_dst->data.ghash) {
- slot_dst->data.ghash = BLI_ghash_ptr_new_ex("bmesh operator 2", BLI_ghash_size(slot_src->data.ghash));
- }
-
for (BLI_ghashIterator_init(&it, slot_src->data.ghash);
(srcmap = BLI_ghashIterator_getValue(&it));
BLI_ghashIterator_step(&it))
@@ -621,12 +624,7 @@
{
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
-
- /* check if its actually a buffer */
- if (!(slot->slot_type == BMO_OP_SLOT_MAPPING))
- return 0;
-
- return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0;
+ return BLI_ghash_size(slot->data.ghash);
}
/* inserts a key/value mapping into a mapping slot. note that it copies the
@@ -645,13 +643,6 @@
mapping->len = len;
memcpy(BMO_OP_SLOT_MAPPING_DATA(mapping), data, len);
- if (!slot->data.ghash) {
- slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
- }
- else {
- BLI_assert(slot->data.ghash);
- }
-
BLI_ghash_insert(slot->data.ghash, (void *)element, mapping);
}
@@ -707,11 +698,11 @@
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
- /* sanity check */
- if (!slot->data.ghash) return;
- BLI_ghashIterator_init(&it, slot->data.ghash);
- for ( ; (ele_f = BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) {
+ for (BLI_ghashIterator_init(&it, slot->data.ghash);
+ (ele_f = BLI_ghashIterator_getKey(&it));
+ BLI_ghashIterator_step(&it))
+ {
if (ele_f->head.htype & htype) {
BMO_elem_flag_enable(bm, ele_f, oflag);
}
@@ -1360,12 +1351,7 @@
iter->restrictmask = restrictmask;
if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) {
- if (iter->slot->data.ghash) {
- BLI_ghashIterator_init(&iter->giter, slot->data.ghash);
- }
- else {
- return NULL;
- }
+ BLI_ghashIterator_init(&iter->giter, slot->data.ghash);
}
else if (iter->slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) {
BLI_assert(restrictmask & slot->slot_subtype.elem);
More information about the Bf-blender-cvs
mailing list