Commit a998a910 authored by Geoff Simmons's avatar Geoff Simmons

Rename the struct for qp tries.

parent 5454faa6
......@@ -44,21 +44,21 @@
#define ANIB(x) AZ((x) & ~0x0f)
struct pt_y {
struct qp_y {
unsigned magic;
#define QP_Y_MAGIC 0x6dfde24a
unsigned idx;
struct pt_y **branch;
struct qp_y **branch;
unsigned short off;
unsigned short len;
uint16_t bitmap;
unsigned char hilo;
};
static struct pt_y *
static struct qp_y *
y_alloc(unsigned idx, unsigned short off, size_t len)
{
struct pt_y *y;
struct qp_y *y;
if (len > USHRT_MAX) {
errno = ERANGE;
......@@ -79,7 +79,7 @@ y_alloc(unsigned idx, unsigned short off, size_t len)
return (y);
}
static inline struct pt_y *
static inline struct qp_y *
y_leaf_alloc(unsigned idx, unsigned char *c, unsigned char *b)
{
return y_alloc(idx, (unsigned short)(uintptr_t)(c - b),
......@@ -87,7 +87,7 @@ y_leaf_alloc(unsigned idx, unsigned char *c, unsigned char *b)
}
static int
y_realloc_branch(struct pt_y * const y, uint16_t bitmap)
y_realloc_branch(struct qp_y * const y, uint16_t bitmap)
{
int len;
uint16_t prev, lobitmap;
......@@ -121,10 +121,10 @@ y_realloc_branch(struct pt_y * const y, uint16_t bitmap)
return (0);
}
static struct pt_y *
y_dup(struct pt_y *y0, unsigned short len)
static struct qp_y *
y_dup(struct qp_y *y0, unsigned short len)
{
struct pt_y *y;
struct qp_y *y;
assert(len < y0->len);
......@@ -139,7 +139,7 @@ y_dup(struct pt_y *y0, unsigned short len)
}
static inline uint16_t
getbits(const struct pt_y * const restrict y, unsigned char c)
getbits(const struct qp_y * const restrict y, unsigned char c)
{
unsigned shift = y->hilo << 2;
unsigned mask = 0x0f << shift;
......@@ -147,16 +147,16 @@ getbits(const struct pt_y * const restrict y, unsigned char c)
}
static inline uint8_t
getidx(const struct pt_y * const restrict y, uint16_t bitmap)
getidx(const struct qp_y * const restrict y, uint16_t bitmap)
{
return (popcount(y->bitmap & (bitmap - 1)));
}
int
QP_Insert(struct pt_y * * restrict root, unsigned idx,
QP_Insert(struct qp_y * * restrict root, unsigned idx,
char * const restrict * const restrict strings)
{
struct pt_y *y;
struct qp_y *y;
unsigned char *c, *b;
AN(root);
......@@ -181,7 +181,7 @@ QP_Insert(struct pt_y * * restrict root, unsigned idx,
unsigned char *s;
uint16_t bitmap;
uint8_t n;
struct pt_y *y_new, *y_old;
struct qp_y *y_new, *y_old;
CHECK_OBJ(y, QP_Y_MAGIC);
......@@ -353,11 +353,11 @@ QP_Insert(struct pt_y * * restrict root, unsigned idx,
}
unsigned
QP_Lookup(const struct pt_y * const restrict root,
QP_Lookup(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
const char * const restrict subject)
{
const struct pt_y *y;
const struct qp_y *y;
size_t len;
AN(strings);
......@@ -392,7 +392,7 @@ QP_Lookup(const struct pt_y * const restrict root,
}
static int
qp_search(const struct pt_y * const restrict y,
qp_search(const struct qp_y * const restrict y,
char * const restrict * const restrict strings,
const unsigned char * restrict subject, size_t len,
struct match_data * const restrict match)
......@@ -446,7 +446,7 @@ qp_search(const struct pt_y * const restrict y,
}
int
QP_Prefixes(const struct pt_y * const restrict root,
QP_Prefixes(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
const char * const restrict subject,
struct match_data * const restrict match)
......@@ -469,7 +469,7 @@ QP_Prefixes(const struct pt_y * const restrict root,
}
void
QP_Free(struct pt_y *y)
QP_Free(struct qp_y *y)
{
if (y == NULL)
return;
......@@ -486,7 +486,7 @@ QP_Free(struct pt_y *y)
}
static void
qp_print_tree(struct pt_y *y, struct vsb *sb, char **strings)
qp_print_tree(struct qp_y *y, struct vsb *sb, char **strings)
{
CHECK_OBJ_NOTNULL(y, QP_Y_MAGIC);
CHECK_OBJ_NOTNULL(sb, VSB_MAGIC);
......@@ -523,7 +523,7 @@ qp_print_tree(struct pt_y *y, struct vsb *sb, char **strings)
}
struct vsb *
QP_Dump(struct pt_y *root, char **strings)
QP_Dump(struct qp_y *root, char **strings)
{
struct vsb *sb = VSB_new_auto();
......@@ -538,7 +538,7 @@ QP_Dump(struct pt_y *root, char **strings)
}
void
qp_stats(const struct pt_y * const restrict y,
qp_stats(const struct qp_y * const restrict y,
char * const restrict * const restrict strings,
struct qp_stats * const restrict stats, unsigned depth)
{
......@@ -581,7 +581,7 @@ qp_stats(const struct pt_y * const restrict y,
}
void
QP_Stats(const struct pt_y * const restrict root,
QP_Stats(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
struct qp_stats * const restrict stats)
{
......
......@@ -32,7 +32,7 @@
#include "vsb.h"
struct pt_y;
struct qp_y;
struct match_data {
unsigned magic;
......@@ -60,17 +60,17 @@ struct qp_stats {
double favg;
};
int QP_Insert(struct pt_y * * restrict root, unsigned idx,
int QP_Insert(struct qp_y * * restrict root, unsigned idx,
char * const restrict * const restrict strings);
unsigned QP_Lookup(const struct pt_y * const restrict root,
unsigned QP_Lookup(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
const char * const restrict subject);
int QP_Prefixes(const struct pt_y * const restrict root,
int QP_Prefixes(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
const char * const restrict subject,
struct match_data * const restrict match);
void QP_Stats(const struct pt_y * const restrict root,
void QP_Stats(const struct qp_y * const restrict root,
char * const restrict * const restrict strings,
struct qp_stats * const restrict stats);
void QP_Free(struct pt_y *y);
struct vsb * QP_Dump(struct pt_y *root, char **strings);
void QP_Free(struct qp_y *y);
struct vsb * QP_Dump(struct qp_y *root, char **strings);
......@@ -54,7 +54,7 @@
#define ITERATIONS (1000)
#define CLOCK (CLOCK_MONOTONIC)
static struct pt_y *origo = NULL;
static struct qp_y *origo = NULL;
static uint64_t
tdiff(struct timespec *before, struct timespec *after)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment