mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 22:09:54 +00:00
[linked-list] range-based for loop iteration over all entries (#6945)
This commit enables use of range-based `for` loop for iterating over all the entries in a `LinkedList`. It adds private implementations of `Iterator` and `ConstIterator` which inherit from `ItemPtrIterator` and use the `GetNext()` to go to the next entry. The range-based `for` loop practically acts as a syntactic sugar helping simplify the code and does not add any code size (or any expected run-time) overhead.
This commit is contained in:
@@ -65,13 +65,13 @@ void VerifyMulticastAddressList(const Ip6::Netif &aNetif, Ip6::Address aAddresse
|
||||
VerifyOrQuit(aNetif.IsMulticastSubscribed(aAddresses[i]));
|
||||
}
|
||||
|
||||
for (const Ip6::Netif::MulticastAddress *addr = aNetif.GetMulticastAddresses(); addr; addr = addr->GetNext())
|
||||
for (const Ip6::Netif::MulticastAddress &addr : aNetif.GetMulticastAddresses())
|
||||
{
|
||||
bool didFind = false;
|
||||
|
||||
for (uint8_t i = 0; i < aLength; i++)
|
||||
{
|
||||
if (addr->GetAddress() == aAddresses[i])
|
||||
if (addr.GetAddress() == aAddresses[i])
|
||||
{
|
||||
didFind = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user