[Groonga-commit] groonga/groonga [master] Use grn_hash_entry in _grn_hash_get_key_value().

Back to archive index

null+****@clear***** null+****@clear*****
2012年 4月 4日 (水) 15:42:58 JST


Susumu Yata	2012-04-04 15:42:58 +0900 (Wed, 04 Apr 2012)

  New Revision: 25373bd7422e24772ccd4fb14990fe63c98c10bf

  Log:
    Use grn_hash_entry in _grn_hash_get_key_value().

  Modified files:
    lib/hash.c

  Modified: lib/hash.c (+16 -7)
===================================================================
--- lib/hash.c    2012-04-04 15:37:55 +0900 (7c1ede3)
+++ lib/hash.c    2012-04-04 15:42:58 +0900 (6a43429)
@@ -2008,13 +2008,22 @@ _grn_hash_get_key_value(grn_ctx *ctx, grn_hash *hash, grn_id id,
                         void **key, void **value)
 {
   int key_size;
-  entry_str *ee;
-  if (!grn_hash_bitmap_at(ctx, hash, id)) { return 0; }
-  ee = grn_hash_entry_at(ctx, hash, id, 0);
-  if (!ee) { return 0; }
-  key_size = (hash->obj.header.flags & GRN_OBJ_KEY_VAR_SIZE) ? ee->size : hash->key_size;
-  *key = get_key(ctx, hash, ee);
-  return (*value = get_value(hash, ee)) ? key_size : 0;
+  grn_hash_entry *entry;
+  if (!grn_hash_bitmap_at(ctx, hash, id)) {
+    return 0;
+  }
+  entry = grn_hash_entry_at(ctx, hash, id, 0);
+  if (!entry) {
+    return 0;
+  }
+  if (hash->obj.header.flags & GRN_OBJ_KEY_VAR_SIZE) {
+    key_size = entry->header.key_size;
+  } else {
+    key_size = hash->key_size;
+  }
+  *key = grn_hash_entry_get_key(ctx, hash, entry);
+  *value = grn_hash_entry_get_value(hash, entry);
+  return *value ? key_size : 0;
 }
 
 grn_rc




Groonga-commit メーリングリストの案内
Back to archive index