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>2011-05-02 17:35:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-02 17:35:04 +0400
commit08d8914b3d0c0028c0f204d499ddfe46a76da113 (patch)
tree39749ad52c1f15627bd061b2fa92bd780dbd4ee0 /source/blender/blenkernel/intern/blender.c
parent6baa456dfdb293f87b7ab4efdf856e7516b4d942 (diff)
reverse string lookup listbase function BLI_findstring counterparts, added BLI_rfindstring, BLI_rfindstring_ptr, these search from the end of the listbase (like pythons rfind).
Diffstat (limited to 'source/blender/blenkernel/intern/blender.c')
-rw-r--r--source/blender/blenkernel/intern/blender.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index ce6a95430e3..75c6303d800 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -619,24 +619,14 @@ void BKE_reset_undo(void)
/* based on index nr it does a restore */
void BKE_undo_number(bContext *C, int nr)
{
- UndoElem *uel;
- int a=1;
-
- for(uel= undobase.first; uel; uel= uel->next, a++) {
- if(a==nr) break;
- }
- curundo= uel;
+ curundo= BLI_findlink(&undobase, nr - 1);
BKE_undo_step(C, 0);
}
/* go back to the last occurance of name in stack */
void BKE_undo_name(bContext *C, const char *name)
{
- UndoElem *uel;
-
- for(uel= undobase.last; uel; uel= uel->prev)
- if(strcmp(name, uel->name)==0)
- break;
+ UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
if(uel && uel->prev) {
curundo= uel->prev;
@@ -648,12 +638,7 @@ void BKE_undo_name(bContext *C, const char *name)
int BKE_undo_valid(const char *name)
{
if(name) {
- UndoElem *uel;
-
- for(uel= undobase.last; uel; uel= uel->prev)
- if(strcmp(name, uel->name)==0)
- break;
-
+ UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
return uel && uel->prev;
}