[Groonga-commit] groonga/grnxx at b037fc6 [master] Update get_pointer() instead of a combination of get() and set().

Back to archive index

susumu.yata null+****@clear*****
Wed Jun 5 09:51:33 JST 2013


susumu.yata	2013-06-05 09:51:33 +0900 (Wed, 05 Jun 2013)

  New Revision: b037fc600dd192fbe100702d60112f29ac007dd6
  https://github.com/groonga/grnxx/commit/b037fc600dd192fbe100702d60112f29ac007dd6

  Message:
    Update get_pointer() instead of a combination of get() and set().

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

  Modified: lib/grnxx/map/bytes_array.cpp (+5 -6)
===================================================================
--- lib/grnxx/map/bytes_array.cpp    2013-06-04 22:25:43 +0900 (3f0f98e)
+++ lib/grnxx/map/bytes_array.cpp    2013-06-05 09:51:33 +0900 (0591e7a)
@@ -102,23 +102,22 @@ bool BytesArray::get(uint64_t value_id, Value *value) {
 }
 
 bool BytesArray::set(uint64_t value_id, ValueArg value) {
-  uint64_t src_bytes_id;
-  if (!ids_->get(value_id, &src_bytes_id)) {
+  uint64_t *src_bytes_id = ids_->get_pointer(value_id);
+  if (!src_bytes_id) {
     return false;
   }
   uint64_t dest_bytes_id;
   if (!store_->add(value, &dest_bytes_id)) {
     return false;
   }
-  if (src_bytes_id != BYTES_STORE_INVALID_BYTES_ID) {
-    if (!store_->unset(src_bytes_id)) {
+  if (*src_bytes_id != BYTES_STORE_INVALID_BYTES_ID) {
+    if (!store_->unset(*src_bytes_id)) {
       // The following unset() may not fail due to the above add().
       store_->unset(dest_bytes_id);
       return false;
     }
   }
-  // The following set() must not fail due to the above get().
-  ids_->set(value_id, dest_bytes_id);
+  *src_bytes_id = dest_bytes_id;
   return true;
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



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