#include "var.h"
#include "vfm.h"
-#undef DEBUGGING
-/*#define DEBUGGING 1 */
#include "debug-print.h"
/* FIXME: This module is less than ideally efficient, both in space
for (i = 0; i < nv_src; i++)
{
struct arc_spec *spec = &t->arc[i];
- void **p = hsh_sort (h_trans[i], NULL);
+ void **p = hsh_sort (h_trans[i]);
int count = hsh_count (h_trans[i]);
int j;
for (j = 0; *p; p++, j++)
{
struct arc_item *item = pool_alloc (arc_pool, sizeof *item);
-
- memcpy (&item->from, *p, sizeof (union value));
- if (v_src[i]->type == ALPHA)
- item->from.c = pool_strdup (arc_pool, item->from.c);
+ union value *vp = *p;
+
+ if (v_src[i]->type == NUMERIC)
+ item->from.f = vp->f;
+ else
+ item->from.c = pool_strdup (arc_pool, vp->c);
item->to = !descend ? j + 1 : count - j;
- force_hsh_insert (spec->items, item);
+ hsh_force_insert (spec->items, item);
}
hsh_destroy (h_trans[i]);
struct arc_item *item;
if (spec->src->type == NUMERIC)
- item = force_hsh_find (spec->items, &c->data[spec->src->fv].f);
+ item = hsh_force_find (spec->items, &c->data[spec->src->fv].f);
else
{
union value v;
v.c = c->data[spec->src->fv].s;
- item = force_hsh_find (spec->items, &v);
+ item = hsh_force_find (spec->items, &v);
}
c->data[spec->dest->fv].f = item->to;
}
static unsigned
-hash_alpha_value (const void *a, void *len)
+hash_alpha_value (const void *a_, void *len)
{
- return hashpjw_d (((union value *) a)->c, &((union value *) a)->c[(int) len]);
+ const union value *a = a_;
+ return hsh_hash_bytes (a->c, (int) len);
}
static int
}
static unsigned
-hash_numeric_value (const void *a, void *len unused)
+hash_numeric_value (const void *a_, void *len unused)
{
- return hashpjw_d ((char *) &((union value *) a)->f,
- (char *) &(&((union value *) a)->f)[1]);
+ const union value *a = a_;
+ return hsh_hash_bytes (&a->f, sizeof a->f);
}
static int
if (NULL == *vpp)
{
vp = pool_alloc (hash_pool, sizeof (union value));
-#if __CHECKER__
- memset (vp, 0, sizeof (union value));
-#endif
- vp->c = pool_strdup (hash_pool, v.c);
+ vp->c = pool_strndup (hash_pool, v.c, v_src[i]->width);
*vpp = vp;
}
}