Skip to content

Commit af892cb

Browse files
committed
small refactor
1 parent 0daf1f8 commit af892cb

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/coord/dist_aggregate.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,14 @@ static int rpnetNext(ResultProcessor *self, SearchResult *r) {
459459

460460
processResultFormat(&nc->areq->reqflags, nc->current.meta);
461461

462-
if (fields && MRReply_Type(fields) == MR_REPLY_MAP) {
463-
for (size_t i = 0; i < MRReply_Length(fields); i += 2) {
464-
size_t len;
465-
const char *field = MRReply_String(MRReply_ArrayElement(fields, i), &len);
466-
MRReply *val = MRReply_ArrayElement(fields, i + 1);
467-
RSValue *v = MRReply_ToValue(val);
468-
RLookup_WriteOwnKeyByName(nc->lookup, field, len, &r->rowdata, v);
469-
}
462+
size_t fields_length = fields && MRReply_Type(fields) == MR_REPLY_MAP ? MRReply_Length(fields) : 0;
463+
464+
for (size_t i = 0; i < fields_length; i += 2) {
465+
size_t len;
466+
const char *field = MRReply_String(MRReply_ArrayElement(fields, i), &len);
467+
MRReply *val = MRReply_ArrayElement(fields, i + 1);
468+
RSValue *v = MRReply_ToValue(val);
469+
RLookup_WriteOwnKeyByName(nc->lookup, field, len, &r->rowdata, v);
470470
}
471471
} else { // RESP2
472472
MRReply *rep = MRReply_ArrayElement(rows, nc->curIdx++);

0 commit comments

Comments
 (0)