From c3f83154adcc66e51faef252684415e7ed876dde Mon Sep 17 00:00:00 2001 From: freemine Date: Fri, 29 Jan 2021 13:51:05 +0800 Subject: [PATCH] add first-place-check to benefit runtime performance --- src/util/src/tref.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/util/src/tref.c b/src/util/src/tref.c index b32680efc4..5c7bdec01e 100644 --- a/src/util/src/tref.c +++ b/src/util/src/tref.c @@ -313,6 +313,11 @@ void *taosIterateRef(int rsetId, int64_t rid) { // rid is there pNode = pNode->next; + // check first place + while (pNode) { + if (!pNode->removed) break; + pNode = pNode->next; + } if (pNode == NULL) { taosUnlockList(pSet->lockedBy+hash); hash++; @@ -323,7 +328,14 @@ void *taosIterateRef(int rsetId, int64_t rid) { for (; hash < pSet->max; ++hash) { taosLockList(pSet->lockedBy+hash); pNode = pSet->nodeList[hash]; - if (pNode) break; + if (pNode) { + // check first place + while (pNode) { + if (!pNode->removed) break; + pNode = pNode->next; + } + if (pNode) break; + } taosUnlockList(pSet->lockedBy+hash); } } -- GitLab