Sped up charset parsing; fixed choice operator
This commit is contained in:
parent
a076c4d12c
commit
2af69dd8f9
5 changed files with 81 additions and 39 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef HAMMER_INTERNAL__H
|
||||
#define HAMMER_INTERNAL__H
|
||||
#include <glib.h>
|
||||
#include "hammer.h"
|
||||
|
||||
#define false 0
|
||||
|
|
@ -10,6 +11,24 @@ typedef struct parser_cache_key {
|
|||
const parser_t *parser;
|
||||
} parser_cache_key_t;
|
||||
|
||||
typedef unsigned int *charset;
|
||||
|
||||
static inline charset new_charset() {
|
||||
charset cs = g_new0(unsigned int, 256 / sizeof(unsigned int));
|
||||
return cs;
|
||||
}
|
||||
|
||||
static inline int charset_isset(charset cs, uint8_t pos) {
|
||||
return !!(cs[pos / sizeof(*cs)] & (1 << (pos % sizeof(*cs))));
|
||||
}
|
||||
|
||||
static inline void charset_set(charset cs, uint8_t pos, int val) {
|
||||
cs[pos / sizeof(*cs)] =
|
||||
val
|
||||
? cs[pos / sizeof(*cs)] | (1 << (pos % sizeof(*cs)))
|
||||
: cs[pos / sizeof(*cs)] & ~(1 << (pos % sizeof(*cs)));
|
||||
}
|
||||
|
||||
// TODO(thequux): Set symbol visibility for these functions so that they aren't exported.
|
||||
|
||||
long long read_bits(input_stream_t* state, int count, char signed_p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue