Use std::unordered_map instead of std::map 36/276736/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 23 Jun 2022 22:34:33 +0000 (07:34 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 23 Jun 2022 22:34:33 +0000 (07:34 +0900)
We usally use std::map as like hash table. Sorting key/value is not needed.

Change-Id: Id2599c6de939dcc216d3511419429b1b84aa297e
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/bundle-internal.cc
src/bundle-internal.h

index 3d14ace..6c3be38 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include "bundle-internal.h"
+
 #include <errno.h>
 #include <glib.h>
 
@@ -21,7 +23,6 @@
 
 #include "include/bundle.h"
 
-#include "bundle-internal.h"
 #include "exception-internal.h"
 
 namespace tizen_base {
@@ -265,7 +266,8 @@ int Bundle::DecodeRaw(unsigned char* raw, int size) {
   return BUNDLE_ERROR_NONE;
 }
 
-const std::map<std::string, std::shared_ptr<KeyInfo>>& Bundle::GetMap() {
+const std::unordered_map<std::string, std::shared_ptr<KeyInfo>>&
+Bundle::GetMap() const {
   return map_;
 }
 
index 136458a..1b46a73 100644 (file)
@@ -18,9 +18,9 @@
 #define BUNDLE_INTERNAL_H_
 
 #include <list>
-#include <map>
 #include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "include/bundle.h"
@@ -72,7 +72,7 @@ class Bundle {
   unsigned char* Encode();
   unsigned char* EncodeRaw(int* size);
   int DecodeRaw(unsigned char* raw, int size);
-  const std::map<std::string, std::shared_ptr<KeyInfo>>& GetMap();
+  const std::unordered_map<std::string, std::shared_ptr<KeyInfo>>& GetMap() const;
   std::vector<std::string> Export();
 
  private:
@@ -80,7 +80,7 @@ class Bundle {
   int Import(int argc, char** argv);
 
  private:
-  std::map<std::string, std::shared_ptr<KeyInfo>> map_;
+  std::unordered_map<std::string, std::shared_ptr<KeyInfo>> map_;
   std::list<std::shared_ptr<KeyInfo>> list_;
 };