[FFmpeg-devel] [PATCH v2 4/6] avutil/tree: Make tree_find_next() non recursive
Michael Niedermayer
michael at niedermayer.cc
Tue Apr 15 21:14:31 EEST 2025
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavutil/tree.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavutil/tree.c b/libavutil/tree.c
index a4c090e6d04..09c55f6752d 100644
--- a/libavutil/tree.c
+++ b/libavutil/tree.c
@@ -40,16 +40,16 @@ struct AVTreeNode *av_tree_node_alloc(void)
static void tree_find_next(const AVTreeNode *t, const void *key,
int (*cmp)(const void *key, const void *b), void *next[4], int nextlen, int direction)
{
- if (t) {
+ while (t) {
unsigned int v = cmp(key, t->elem);
if (v) {
next[direction] = t->elem;
av_assert2((v >> 31) == direction);
- tree_find_next(t->child[!direction], key, cmp, next, nextlen, direction);
+ t = t->child[!direction];
} else {
if (nextlen >= 4)
next[2+direction] = t->elem;
- tree_find_next(t->child[direction], key, cmp, next, nextlen, direction);
+ t = t->child[direction];
}
}
}
--
2.49.0
More information about the ffmpeg-devel
mailing list