Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed 0b05158

Inlined the methods.

  • Participants
  • Parent commits 22b3bae

Comments (0)

Files changed (2)

File black-hole-solitaire/c-solver/tokyo_cab_hash.c

 #include "tokyo_cab_hash.h"
 #include "state.h"
 
-void bh_solve_hash_init(
-    bh_solve_hash_t * hash
-    )
-{
-    int ecode;
-
-    hash->hash = tchdbnew();
-    tchdbsetcache(hash->hash, 1024*1024);
-    if (!tchdbopen(hash->hash, "bh_solve.hdb", HDBOWRITER|HDBOTRUNC|HDBOCREAT))
-    {
-        ecode = tchdbecode(hash->hash);
-        fprintf(stderr, "Tokyo Cabinet open error: %s\n", tchdberrmsg(ecode));
-        exit(-1);
-    }
-    return;
-}
-
-fcs_bool_t bh_solve_hash_insert(
-    bh_solve_hash_t * hash,
-    bhs_state_key_value_pair_t * key
-)
-{
-    return (!tchdbputkeep(
-        hash->hash,
-        &(key->key),
-        sizeof(key->key),
-        &(key->value),
-        sizeof(key->value)
-    ));
-}
-
 #else
 
 /* ANSI C doesn't allow empty compilation */

File black-hole-solitaire/c-solver/tokyo_cab_hash.h

     TCHDB * hash;
 } bh_solve_hash_t;
 
-extern void
-bh_solve_hash_init(
+static GCC_INLINE void bh_solve_hash_init(
     bh_solve_hash_t * hash
-    );
+    )
+{
+    int ecode;
+
+    hash->hash = tchdbnew();
+    tchdbsetcache(hash->hash, 1024*1024);
+    if (!tchdbopen(hash->hash, "bh_solve.hdb", HDBOWRITER|HDBOTRUNC|HDBOCREAT))
+    {
+        ecode = tchdbecode(hash->hash);
+        fprintf(stderr, "Tokyo Cabinet open error: %s\n", tchdberrmsg(ecode));
+        exit(-1);
+    }
+    return;
+}
+
+
+static GCC_INLINE fcs_bool_t bh_solve_hash_insert(
+    bh_solve_hash_t * hash,
+    bhs_state_key_value_pair_t * key
+)
+{
+    return (!tchdbputkeep(
+        hash->hash,
+        &(key->key),
+        sizeof(key->key),
+        &(key->value),
+        sizeof(key->value)
+    ));
+}
 
 /*
  * Returns FALSE if the key is new and the key/val pair was inserted.