Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-selector
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-selector
Commits
a998a910
Commit
a998a910
authored
Mar 06, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the struct for qp tries.
parent
5454faa6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
31 deletions
+31
-31
qp.c
src/qp.c
+23
-23
qp.h
src/qp.h
+7
-7
bench_qp.c
src/tests/bench/bench_qp.c
+1
-1
No files found.
src/qp.c
View file @
a998a910
...
...
@@ -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
)
{
...
...
src/qp.h
View file @
a998a910
...
...
@@ -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
);
src/tests/bench/bench_qp.c
View file @
a998a910
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment