[Groonga-commit] groonga/grnxx at 9cb61a2 [master] Inline grnxx::map::BytesArray::get().

Back to archive index

susumu.yata null+****@clear*****
Fri Jul 19 12:03:21 JST 2013


susumu.yata	2013-07-19 12:03:21 +0900 (Fri, 19 Jul 2013)

  New Revision: 9cb61a272e06ae379c61f0b190493e7822d0da99
  https://github.com/groonga/grnxx/commit/9cb61a272e06ae379c61f0b190493e7822d0da99

  Message:
    Inline grnxx::map::BytesArray::get().

  Modified files:
    lib/grnxx/map/bytes_array.cpp
    lib/grnxx/map/bytes_array.hpp

  Modified: lib/grnxx/map/bytes_array.cpp (+0 -15)
===================================================================
--- lib/grnxx/map/bytes_array.cpp    2013-07-18 19:49:38 +0900 (aaaca01)
+++ lib/grnxx/map/bytes_array.cpp    2013-07-19 12:03:21 +0900 (01163b9)
@@ -22,16 +22,10 @@
 
 #include "grnxx/exception.hpp"
 #include "grnxx/logger.hpp"
-#include "grnxx/map/bytes_pool.hpp"
 #include "grnxx/storage.hpp"
 
 namespace grnxx {
 namespace map {
-namespace {
-
-constexpr uint64_t INVALID_BYTES_ID = ~0ULL;
-
-}  // namespace
 
 struct BytesArrayHeader {
   uint64_t default_value_size;
@@ -87,15 +81,6 @@ void BytesArray::unlink(Storage *storage, uint32_t storage_node_id) {
   storage->unlink_node(storage_node_id);
 }
 
-auto BytesArray::get(uint64_t value_id) -> Value {
-  uint64_t bytes_id = ids_->get(value_id);
-  if (bytes_id == INVALID_BYTES_ID) {
-    return default_value_;
-  } else {
-    return pool_->get(bytes_id);
-  }
-}
-
 void BytesArray::set(uint64_t value_id, ValueArg value) {
   uint64_t * const src_bytes_id = &ids_->get_value(value_id);
   const uint64_t dest_bytes_id = pool_->add(value);

  Modified: lib/grnxx/map/bytes_array.hpp (+11 -1)
===================================================================
--- lib/grnxx/map/bytes_array.hpp    2013-07-18 19:49:38 +0900 (125a808)
+++ lib/grnxx/map/bytes_array.hpp    2013-07-19 12:03:21 +0900 (95324e2)
@@ -25,6 +25,7 @@
 #include "grnxx/array.hpp"
 #include "grnxx/bytes.hpp"
 #include "grnxx/duration.hpp"
+#include "grnxx/map/bytes_pool.hpp"
 #include "grnxx/traits.hpp"
 #include "grnxx/types.hpp"
 
@@ -39,6 +40,8 @@ class BytesPool;
 struct BytesArrayHeader;
 
 class BytesArray {
+  static constexpr uint64_t INVALID_BYTES_ID = ~0ULL;
+
  public:
   using Value = typename Traits<Bytes>::Type;
   using ValueArg = typename Traits<Bytes>::ArgumentType;
@@ -70,7 +73,14 @@ class BytesArray {
   }
 
   // Get a value.
-  Value get(uint64_t value_id);
+  Value get(uint64_t value_id) {
+    const uint64_t bytes_id = ids_->get(value_id);
+    if (bytes_id == INVALID_BYTES_ID) {
+      return default_value_;
+    } else {
+      return pool_->get(bytes_id);
+    }
+  }
   // Set a value.
   void set(uint64_t value_id, ValueArg value);
 
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index