[Groonga-commit] groonga/groonga [master] Replace KEY_AT() with grn_hash_key_at().

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 29日 (木) 18:58:29 JST


Susumu Yata	2012-03-29 18:58:29 +0900 (Thu, 29 Mar 2012)

  New Revision: eb43c15ce7f94282f9dc96c07d4480f1d4c27681

  Log:
    Replace KEY_AT() with grn_hash_key_at().

  Modified files:
    lib/hash.c

  Modified: lib/hash.c (+10 -9)
===================================================================
--- lib/hash.c    2012-03-29 18:52:37 +0900 (a920d74)
+++ lib/hash.c    2012-03-29 18:58:29 +0900 (c34984c)
@@ -889,10 +889,14 @@ grn_hash_idx_at(grn_ctx *ctx, grn_hash *hash, grn_id id)
   }
 }
 
-#define KEY_AT(hash,pos,ptr) do {\
-  int flags = GRN_TABLE_ADD;\
-  GRN_IO_ARRAY_AT(hash->io, segment_key, pos, &flags, ptr);\
-} while (0)
+inline static void *
+grn_hash_key_at(grn_ctx *ctx, grn_hash *hash, uint32_t pos)
+{
+  int flags = GRN_TABLE_ADD;
+  void *key;
+  GRN_IO_ARRAY_AT(hash->io, segment_key, pos, &flags, key);
+  return key;
+}
 
 #define HASH_IMMEDIATE 1
 
@@ -906,9 +910,7 @@ get_key(grn_ctx *ctx, grn_hash *hash, entry_str *n)
       return (char *)&n->str;
     } else {
       if (IO_HASHP(hash)) {
-        char *res;
-        KEY_AT(hash, n->str, res);
-        return res;
+        return (char *)grn_hash_key_at(ctx, hash, n->str);
       } else {
         return ((entry_astr *)n)->str;
       }
@@ -957,8 +959,7 @@ put_key_(grn_ctx *ctx, grn_hash *hash, entry_str *n, const char *key, int len)
     n->str = res;
   }
   {
-    uint8_t *dest;
-    KEY_AT(hash, res, dest);
+    void * const dest = grn_hash_key_at(ctx, hash, res);
     if (!dest) { return; }
     memcpy(dest, key, len);
   }




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