/* Fast fuzzy searching among messages.
- Copyright (C) 2006, 2008, 2011, 2013, 2023 Free Software Foundation, Inc.
+ Copyright (C) 2006-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
size_t len1 = accu->nitems;
size_t len2 = list[IL_LENGTH];
size_t need = len1 + len2;
- struct mult_index *ptr1;
- struct mult_index *ptr1_end;
index_ty *ptr2;
index_ty *ptr2_end;
struct mult_index *destptr;
}
/* Make a linear pass through accu and list simultaneously. */
- ptr1 = accu->item;
- ptr1_end = ptr1 + len1;
ptr2 = list + 2;
ptr2_end = ptr2 + len2;
destptr = accu->item2;
- while (ptr1 < ptr1_end && ptr2 < ptr2_end)
+ if (len1 > 0)
{
- if (ptr1->index < *ptr2)
- {
- *destptr = *ptr1;
- ptr1++;
- }
- else if (ptr1->index > *ptr2)
+ struct mult_index *ptr1;
+ struct mult_index *ptr1_end;
+
+ ptr1 = accu->item;
+ ptr1_end = ptr1 + len1;
+ while (ptr1 < ptr1_end && ptr2 < ptr2_end)
{
- destptr->index = *ptr2;
- destptr->count = 1;
- ptr2++;
+ if (ptr1->index < *ptr2)
+ {
+ *destptr = *ptr1;
+ ptr1++;
+ }
+ else if (ptr1->index > *ptr2)
+ {
+ destptr->index = *ptr2;
+ destptr->count = 1;
+ ptr2++;
+ }
+ else /* ptr1->index == list[2 + i2] */
+ {
+ destptr->index = ptr1->index;
+ destptr->count = ptr1->count + 1;
+ ptr1++;
+ ptr2++;
+ }
+ destptr++;
}
- else /* ptr1->index == list[2 + i2] */
+ while (ptr1 < ptr1_end)
{
- destptr->index = ptr1->index;
- destptr->count = ptr1->count + 1;
+ *destptr = *ptr1;
ptr1++;
- ptr2++;
+ destptr++;
}
- destptr++;
- }
- while (ptr1 < ptr1_end)
- {
- *destptr = *ptr1;
- ptr1++;
- destptr++;
}
while (ptr2 < ptr2_end)
{