From: Kimmo Hoikka Date: Fri, 26 May 2017 12:58:51 +0000 (+0100) Subject: Removal of unnecessary set and map wrappers X-Git-Tag: dali_1.2.42~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=eaa240e434cc060712ced1f0345a8940ac46216e Removal of unnecessary set and map wrappers Change-Id: I9ed0d50dc3c9130f2973de49e94c4e8b69a1479b --- diff --git a/adaptors/common/singleton-service-impl.cpp b/adaptors/common/singleton-service-impl.cpp index 8ab6bda..d975d94 100644 --- a/adaptors/common/singleton-service-impl.cpp +++ b/adaptors/common/singleton-service-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ void SingletonService::Register( const std::type_info& info, BaseHandle singleto if( singleton ) { DALI_LOG_SINGLETON_SERVICE( Debug::General, "Singleton Added: %s\n", info.name() ); - mSingletonContainer.insert( SingletonPair( info.name(), singleton ) ); + mSingletonContainer.push_back( SingletonPair( info.name(), singleton ) ); } } @@ -88,10 +88,14 @@ BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const { BaseHandle object; - SingletonConstIter iter = mSingletonContainer.find(info.name()); - if( iter != mSingletonContainer.end() ) + const SingletonContainer::const_iterator end = mSingletonContainer.end(); + for( SingletonContainer::const_iterator iter = mSingletonContainer.begin(); iter != end; ++iter ) { - object = ( *iter ).second; + // comparing the addresses as these are allocated statically per library + if( ( *iter ).first == info.name() ) + { + object = ( *iter ).second; + } } return object; diff --git a/adaptors/common/singleton-service-impl.h b/adaptors/common/singleton-service-impl.h index e5d623c..3e74522 100644 --- a/adaptors/common/singleton-service-impl.h +++ b/adaptors/common/singleton-service-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_SINGLETON_SERVICE_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ // EXTERNAL INCLUDES #include -#include +#include // INTERNAL INCLUDES #include @@ -84,8 +84,10 @@ private: private: - typedef std::pair SingletonPair; - typedef std::map SingletonContainer; + // using the address of the type name string as compiler will allocate these once per library + // and we don't support un/re-loading of dali libraries while singleton service is alive + typedef std::pair< const char*, BaseHandle> SingletonPair; + typedef std::vector< SingletonPair > SingletonContainer; typedef SingletonContainer::const_iterator SingletonConstIter; SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name