other: code optimization for exp/del msg

This commit is contained in:
Cary Xu 2022-06-04 19:34:53 +08:00
parent bae6bed2bd
commit fc4c08ef46
2 changed files with 8 additions and 10 deletions

View File

@ -2409,7 +2409,7 @@ typedef struct {
int64_t indexUid; int64_t indexUid;
int8_t flags; // 0x1 all window expired int8_t flags; // 0x1 all window expired
int32_t numExpWnds; int32_t numExpWnds;
TSKEY* wndSKeys[]; TSKEY wndSKeys[];
} SVGetTsmaExpWndsRsp; } SVGetTsmaExpWndsRsp;
int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder* pCoder, const SVGetTsmaExpWndsReq* pReq); int32_t tEncodeSVGetTSmaExpWndsReq(SEncoder* pCoder, const SVGetTsmaExpWndsReq* pReq);

View File

@ -3771,7 +3771,7 @@ int32_t tEncodeSVGetTSmaExpWndsRsp(SEncoder* pCoder, const SVGetTsmaExpWndsRsp*
if (tEncodeI8(pCoder, pReq->flags) < 0) return -1; if (tEncodeI8(pCoder, pReq->flags) < 0) return -1;
if (tEncodeI32(pCoder, pReq->numExpWnds) < 0) return -1; if (tEncodeI32(pCoder, pReq->numExpWnds) < 0) return -1;
for (int32_t i = 0; i < pReq->numExpWnds; ++i) { for (int32_t i = 0; i < pReq->numExpWnds; ++i) {
if (tEncodeI64(pCoder, *(int64_t*)((TSKEY*)pReq->wndSKeys + i)) < 0) return -1; if (tEncodeI64(pCoder, pReq->wndSKeys[i]) < 0) return -1;
} }
tEndEncode(pCoder); tEndEncode(pCoder);
return 0; return 0;
@ -3784,7 +3784,7 @@ int32_t tDecodeSVGetTsmaExpWndsRsp(SDecoder* pCoder, SVGetTsmaExpWndsRsp* pReq)
if (tDecodeI8(pCoder, &pReq->flags) < 0) return -1; if (tDecodeI8(pCoder, &pReq->flags) < 0) return -1;
if (tDecodeI32(pCoder, &pReq->numExpWnds) < 0) return -1; if (tDecodeI32(pCoder, &pReq->numExpWnds) < 0) return -1;
for (int32_t i = 0; i < pReq->numExpWnds; ++i) { for (int32_t i = 0; i < pReq->numExpWnds; ++i) {
if (tDecodeI64(pCoder, (TSKEY*)pReq->wndSKeys + i) < 0) return -1; if (tDecodeI64(pCoder, &pReq->wndSKeys[i]) < 0) return -1;
} }
tEndDecode(pCoder); tEndDecode(pCoder);
@ -3801,9 +3801,8 @@ int32_t tEncodeSVDeleteReq(SEncoder* pCoder, const SVDeleteReq* pReq) {
if (tEncodeCStr(pCoder, pReq->tbFullName) < 0) return -1; if (tEncodeCStr(pCoder, pReq->tbFullName) < 0) return -1;
if (tEncodeCStr(pCoder, pReq->subPlan) < 0) return -1; if (tEncodeCStr(pCoder, pReq->subPlan) < 0) return -1;
for (int16_t i = 0; i < pReq->nWnds; ++i) { for (int16_t i = 0; i < pReq->nWnds; ++i) {
STimeWindow* wnd = (STimeWindow*)pReq->wnds + i; if (tEncodeI64(pCoder, pReq->wnds[i].skey) < 0) return -1;
if (tEncodeI64(pCoder, wnd->skey) < 0) return -1; if (tEncodeI64(pCoder, pReq->wnds[i].ekey) < 0) return -1;
if (tEncodeI64(pCoder, wnd->ekey) < 0) return -1;
} }
tEndEncode(pCoder); tEndEncode(pCoder);
@ -3820,9 +3819,8 @@ int32_t tDecodeSVDeleteReq(SDecoder* pCoder, SVDeleteReq* pReq) {
if (tDecodeCStr(pCoder, &pReq->tbFullName) < 0) return -1; if (tDecodeCStr(pCoder, &pReq->tbFullName) < 0) return -1;
if (tDecodeCStr(pCoder, &pReq->subPlan) < 0) return -1; if (tDecodeCStr(pCoder, &pReq->subPlan) < 0) return -1;
for (int16_t i = 0; i < pReq->nWnds; ++i) { for (int16_t i = 0; i < pReq->nWnds; ++i) {
STimeWindow* wnd = (STimeWindow*)pReq->wnds + i; if (tDecodeI64(pCoder, &pReq->wnds[i].skey) < 0) return -1;
if (tDecodeI64(pCoder, &wnd->skey) < 0) return -1; if (tDecodeI64(pCoder, &pReq->wnds[i].ekey) < 0) return -1;
if (tDecodeI64(pCoder, &wnd->ekey) < 0) return -1;
} }
tEndDecode(pCoder); tEndDecode(pCoder);