From 9049a2424fb28732c7cf8dda195f5c7d9d7e91a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E5=8D=8E=E5=81=A5?= Date: Thu, 16 Sep 2021 17:18:27 +0800 Subject: [PATCH] [Optimize][Stream load] Speed up stream load 3x --- be/src/olap/skiplist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/be/src/olap/skiplist.h b/be/src/olap/skiplist.h index 1cd5bee71ed765..96c9d8990c38be 100644 --- a/be/src/olap/skiplist.h +++ b/be/src/olap/skiplist.h @@ -264,9 +264,9 @@ inline void SkipList::Iterator::SeekToLast() { template int SkipList::RandomHeight() { // Increase height with probability 1 in kBranching - static const unsigned int kBranching = 4; int height = 1; - while (height < kMaxHeight && ((rnd_.Next() % kBranching) == 0)) { + // "& 3" equals to "% 4", and more faster. 4 is kBranching + while (height < kMaxHeight && ((rnd_.Next() & 3) == 0)) { height++; } DCHECK(height > 0);