From 2a3f13e1c7e42dc701abd1a51f352cdd8f1d3d4b Mon Sep 17 00:00:00 2001 From: Li Cao Date: Fri, 29 Jan 2021 02:43:57 +0800 Subject: [PATCH] [child-table] enhance address iterator method (#6118) Moving the if statement out of the loop always brings the same result. --- src/core/thread/topology.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/thread/topology.cpp b/src/core/thread/topology.cpp index 3c94c34d6..da00b2c9f 100644 --- a/src/core/thread/topology.cpp +++ b/src/core/thread/topology.cpp @@ -255,13 +255,13 @@ void Child::AddressIterator::Update(void) { const Ip6::Address *address; + if ((mIndex == 0) && (mChild.GetMeshLocalIp6Address(mMeshLocalAddress) != OT_ERROR_NONE)) + { + mIndex++; + } + while (true) { - if ((mIndex == 0) && (mChild.GetMeshLocalIp6Address(mMeshLocalAddress) != OT_ERROR_NONE)) - { - mIndex++; - } - address = GetAddress(); VerifyOrExit((address != nullptr) && !address->IsUnspecified(), mIndex = kMaxIndex);