From 72aa8d0b3e89f2e4bf9612f1d75afdf18dca8352 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 22 Jan 2019 09:13:24 -0800 Subject: [PATCH] [router-table] reuse const method `GetRouter()` in related non-const version (#3483) --- src/core/thread/router_table.cpp | 18 ------------------ src/core/thread/router_table.hpp | 5 ++++- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/core/thread/router_table.cpp b/src/core/thread/router_table.cpp index 32d7d8713..4e3499d41 100644 --- a/src/core/thread/router_table.cpp +++ b/src/core/thread/router_table.cpp @@ -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; diff --git a/src/core/thread/router_table.hpp b/src/core/thread/router_table.hpp index d1aa74f39..7e63973af 100644 --- a/src/core/thread/router_table.hpp +++ b/src/core/thread/router_table.hpp @@ -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(const_cast(this)->GetRouter(aRouterId)); + } /** * This method returns the router for a given router id.