BStringList: update DoForEach to abort the iteration early.
* This matches `BList::DoForEach`, and the passed in function was already returning a boolean, but was not used. Change-Id: Ifac94734b6181663726cb7aaa7966c5c0ca59bc8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5337 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
a0a83410c4
commit
5e5bb3318e
@@ -296,9 +296,10 @@ BStringList::Join(const char* separator, int32 length) const
|
||||
void
|
||||
BStringList::DoForEach(bool (*func)(const BString& string))
|
||||
{
|
||||
bool terminate = false;
|
||||
int32 count = fStrings.CountItems();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
func(StringAt(i));
|
||||
for (int32 i = 0; i < count && !terminate; i++)
|
||||
terminate = func(StringAt(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -306,9 +307,10 @@ void
|
||||
BStringList::DoForEach(bool (*func)(const BString& string, void* arg2),
|
||||
void* arg2)
|
||||
{
|
||||
bool terminate = false;
|
||||
int32 count = fStrings.CountItems();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
func(StringAt(i), arg2);
|
||||
for (int32 i = 0; i < count && !terminate; i++)
|
||||
terminate = func(StringAt(i), arg2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user