Refactored all of the desugaring code to no longer depend on memory being initialized to 0. Everything is about 12% faster now.

This commit is contained in:
Dan Hirsch 2013-05-25 03:35:42 +02:00
parent d71215d494
commit ec404ca8fe
36 changed files with 411 additions and 417 deletions

View file

@ -3,6 +3,7 @@
#include "../hammer.h"
#include "../internal.h"
#include "../backends/regex.h"
#include "../backends/contextfree.h"
#define a_new_(arena, typ, count) ((typ*)h_arena_malloc((arena), sizeof(typ)*(count)))
#define a_new(typ, count) a_new_(state->arena, typ, count)
@ -25,17 +26,12 @@ static inline size_t token_length(HParseResult *pr) {
}
/* Epsilon rules happen during desugaring. This handles them. */
static inline HCFChoice* desugar_epsilon(HAllocator *mm__, void *env) {
static HCFChoice *res_seq_l[] = {NULL};
static HCFSequence res_seq = {res_seq_l};
static HCFSequence *res_ch_l[] = {&res_seq, NULL};
static HCFChoice res_ch = {
.type = HCF_CHOICE,
.seq = res_ch_l,
.action = NULL,
.reshape = h_act_ignore
};
return &res_ch;
static inline void desugar_epsilon(HAllocator *mm__, HCFStack *stk__, void *env) {
HCFS_BEGIN_CHOICE() {
HCFS_BEGIN_SEQ() {
} HCFS_END_SEQ();
HCFS_THIS_CHOICE->reshape = h_act_ignore;
} HCFS_END_CHOICE();
}
#endif // HAMMER_PARSE_INTERNAL__H