[router-table] reuse const method GetRouter() in related non-const version (#3483)

This commit is contained in:
Abtin Keshavarzian
2019-01-22 09:13:24 -08:00
committed by Jonathan Hui
parent f9eb4cb517
commit 72aa8d0b3e
2 changed files with 4 additions and 19 deletions
-18
View File
@@ -395,24 +395,6 @@ exit:
return router;
}
Router *RouterTable::GetRouter(uint8_t aRouterId)
{
Router * rval = NULL;
uint16_t rloc16 = Mle::Mle::GetRloc16(aRouterId);
for (uint8_t i = 0; i < Mle::kMaxRouters; i++)
{
if (mRouters[i].GetRloc16() == rloc16)
{
rval = &mRouters[i];
ExitNow();
}
}
exit:
return rval;
}
const Router *RouterTable::GetRouter(uint8_t aRouterId) const
{
const Router *rval = NULL;
+4 -1
View File
@@ -238,7 +238,10 @@ public:
* @returns A pointer to the router or NULL if the router could not be found.
*
*/
Router *GetRouter(uint8_t aRouterId);
Router *GetRouter(uint8_t aRouterId)
{
return const_cast<Router *>(const_cast<const RouterTable *>(this)->GetRouter(aRouterId));
}
/**
* This method returns the router for a given router id.