Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-28 23:33:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-28 23:33:14 +0400
commit4f90d757c79bc665c9e4d1cd32573d47e76d2ddd (patch)
tree6c4d74e8f9c985254e36304764e9b31eb3d15d53 /source/blender/editors/curve
parent131de4352b9e8f3e4ce77d2d9dc145f5db461aed (diff)
add BLI_ghash_pop() which returns the value for a key and removes it at the same time, saves a lookup if you need to check if the item exists before removing.
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/editcurve.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 492111ff8e7..b94d3653f60 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -356,6 +356,11 @@ static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv)
return BLI_ghash_lookup(editnurb->keyindex, cv);
}
+static CVKeyIndex *popCVKeyIndex(EditNurb *editnurb, void *cv)
+{
+ return BLI_ghash_pop(editnurb->keyindex, cv, NULL);
+}
+
static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, BezTriple *bezt)
{
CVKeyIndex *index = getCVKeyIndex(editnurb, bezt);
@@ -459,9 +464,7 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv,
}
for (i = 0; i < count; i++) {
- index = getCVKeyIndex(editnurb, cv);
-
- BLI_ghash_remove(editnurb->keyindex, cv, NULL, NULL);
+ index = popCVKeyIndex(editnurb, cv);
if (index) {
BLI_ghash_insert(editnurb->keyindex, newcv, index);
@@ -496,11 +499,8 @@ static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu)
static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
{
- CVKeyIndex *index1 = getCVKeyIndex(editnurb, a);
- CVKeyIndex *index2 = getCVKeyIndex(editnurb, b);
-
- BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL);
- BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL);
+ CVKeyIndex *index1 = popCVKeyIndex(editnurb, a);
+ CVKeyIndex *index2 = popCVKeyIndex(editnurb, b);
if (index2) BLI_ghash_insert(editnurb->keyindex, a, index2);
if (index1) BLI_ghash_insert(editnurb->keyindex, b, index1);