refactor builder struct
This commit is contained in:
parent
7ee1cf62ca
commit
716c0045f8
|
@ -82,8 +82,8 @@ typedef struct FstSlice {
|
|||
FstSlice fstSliceCreate(uint8_t *data, uint64_t len);
|
||||
FstSlice fstSliceCopy(FstSlice *s, int32_t start, int32_t end);
|
||||
FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end);
|
||||
bool fstSliceEmpty(FstSlice *s);
|
||||
int fstSliceCompare(FstSlice *s1, FstSlice *s2);
|
||||
bool fstSliceIsEmpty(FstSlice *s);
|
||||
int fstSliceCompare(FstSlice *s1, FstSlice *s2);
|
||||
void fstSliceDestroy(FstSlice *s);
|
||||
uint8_t *fstSliceData(FstSlice *s, int32_t *sz);
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void fstUnFinishedNodesTopLastFreeze(FstUnFinishedNodes *nodes, CompiledAddr add
|
|||
}
|
||||
void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output out) {
|
||||
FstSlice *s = &bs;
|
||||
if (fstSliceEmpty(s)) {
|
||||
if (fstSliceIsEmpty(s)) {
|
||||
return;
|
||||
}
|
||||
size_t sz = taosArrayGetSize(nodes->stack) - 1;
|
||||
|
@ -801,7 +801,7 @@ bool fstBuilderInsert(FstBuilder *b, FstSlice bs, Output in) {
|
|||
|
||||
void fstBuilderInsertOutput(FstBuilder *b, FstSlice bs, Output in) {
|
||||
FstSlice *s = &bs;
|
||||
if (fstSliceEmpty(s)) {
|
||||
if (fstSliceIsEmpty(s)) {
|
||||
b->len = 1;
|
||||
fstUnFinishedNodesSetRootOutput(b->unfinished, in);
|
||||
return;
|
||||
|
@ -831,7 +831,7 @@ void fstBuilderInsertOutput(FstBuilder *b, FstSlice bs, Output in) {
|
|||
|
||||
OrderType fstBuilderCheckLastKey(FstBuilder *b, FstSlice bs, bool ckDup) {
|
||||
FstSlice *input = &bs;
|
||||
if (fstSliceEmpty(&b->last)) {
|
||||
if (fstSliceIsEmpty(&b->last)) {
|
||||
// deep copy or not
|
||||
b->last = fstSliceCopy(&bs, input->start, input->end);
|
||||
} else {
|
||||
|
@ -1115,7 +1115,7 @@ bool fstBoundWithDataIsEmpty(FstBoundWithData *bound) {
|
|||
if (bound->type == Unbounded) {
|
||||
return true;
|
||||
} else {
|
||||
return fstSliceEmpty(&bound->data);
|
||||
return fstSliceIsEmpty(&bound->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) {
|
|||
assert(tlen <= alen);
|
||||
|
||||
uint8_t *buf = malloc(sizeof(uint8_t) * tlen);
|
||||
memcpy(buf, data, tlen);
|
||||
memcpy(buf, data + start, tlen);
|
||||
|
||||
FstString *str = malloc(sizeof(FstString));
|
||||
str->data = buf;
|
||||
|
@ -135,7 +135,7 @@ FstSlice fstSliceDeepCopy(FstSlice *s, int32_t start, int32_t end) {
|
|||
ans.end = tlen - 1;
|
||||
return ans;
|
||||
}
|
||||
bool fstSliceEmpty(FstSlice *s) {
|
||||
bool fstSliceIsEmpty(FstSlice *s) {
|
||||
return s->str == NULL || s->start < 0 || s->end < 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue