aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/reflist.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src/reflist.c')
-rw-r--r--libcrystfel/src/reflist.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c
index b3b9f85b..a450d8fa 100644
--- a/libcrystfel/src/reflist.c
+++ b/libcrystfel/src/reflist.c
@@ -992,12 +992,20 @@ Reflection *first_refl(RefList *list, RefListIterator **piter)
**/
Reflection *next_refl(Reflection *refl, RefListIterator *iter)
{
- int returned = 1;
+ /* Are there more reflections with the same indices? */
+ if ( refl->next != NULL ) {
+ return refl->next;
+ } else {
- do {
+ /* No, so rewind back to the head of the list */
+ while ( refl->prev != NULL ) {
+ refl = refl->prev;
+ }
+
+ }
- if ( returned ) refl = refl->child[1];
- returned = 0;
+ refl = refl->child[1];
+ do {
if ( refl != NULL ) {
@@ -1041,13 +1049,21 @@ static int recursive_depth(Reflection *refl)
static int recursive_count(Reflection *refl)
{
int count_left, count_right;
+ Reflection *probe;
+ int n_this = 1;
if ( refl == NULL ) return 0;
+ probe = refl;
+ while ( probe->next != NULL ) {
+ probe = probe->next;
+ n_this++;
+ }
+
count_left = recursive_count(refl->child[0]);
count_right = recursive_count(refl->child[1]);
- return 1 + count_left + count_right;
+ return n_this + count_left + count_right;
}