[network-data] remove redudnant code from RegisterNetworkData() (#4562)

This commit is contained in:
Jonathan Hui
2020-02-18 09:50:57 -08:00
parent 8079570ccf
commit d52f893b35
+10 -17
View File
@@ -722,8 +722,7 @@ exit:
otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLength)
{
otError error = OT_ERROR_NONE;
bool stableUpdated = false;
otError error = OT_ERROR_NONE;
bool rlocIn;
bool rlocStable;
bool unused;
@@ -742,33 +741,27 @@ otError Leader::RegisterNetworkData(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aT
{
if (IsStableUpdated(aTlvs, aTlvsLength, mTlvs, mLength) || IsStableUpdated(mTlvs, mLength, aTlvs, aTlvsLength))
{
stableUpdated = true;
rlocStable = true;
}
// Store old Service IDs for given rloc16, so updates to server will reuse the same Service ID
SuccessOrExit(error = GetNetworkData(false, oldTlvs, oldTlvsLength));
RemoveRloc(aRloc16, kMatchModeRloc16);
SuccessOrExit(error = AddNetworkData(aTlvs, aTlvsLength, oldTlvs, oldTlvsLength));
mVersion++;
if (stableUpdated)
{
mStableVersion++;
}
}
else
{
// No old data to be preserved, lets avoid memcpy() & FindService calls.
SuccessOrExit(error = AddNetworkData(aTlvs, aTlvsLength, oldTlvs, 0));
oldTlvsLength = 0;
}
mVersion++;
SuccessOrExit(error = AddNetworkData(aTlvs, aTlvsLength, oldTlvs, oldTlvsLength));
if (rlocStable)
{
mStableVersion++;
}
mVersion++;
if (rlocStable)
{
mStableVersion++;
}
Get<Notifier>().Signal(OT_CHANGED_THREAD_NETDATA);