From 71a36d239656273e746d5c75391e205c2bc8d58f Mon Sep 17 00:00:00 2001 From: Jeanette Tan Date: Thu, 19 Oct 2023 13:17:46 +0800 Subject: [PATCH] Very minor refactor of the integer overflow fix Signed-off-by: Jeanette Tan --- tsdb/ooo_head_read.go | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/tsdb/ooo_head_read.go b/tsdb/ooo_head_read.go index c30c2b565..242d19eed 100644 --- a/tsdb/ooo_head_read.go +++ b/tsdb/ooo_head_read.go @@ -178,42 +178,36 @@ type chunkMetaAndChunkDiskMapperRef struct { } func refLessByMinTimeAndMinRef(a, b chunkMetaAndChunkDiskMapperRef) int { - if a.meta.MinTime == b.meta.MinTime { - switch { - case a.meta.Ref < b.meta.Ref: - return -1 - case a.meta.Ref > b.meta.Ref: - return 1 - default: - return 0 - } - } switch { case a.meta.MinTime < b.meta.MinTime: return -1 case a.meta.MinTime > b.meta.MinTime: return 1 + } + + switch { + case a.meta.Ref < b.meta.Ref: + return -1 + case a.meta.Ref > b.meta.Ref: + return 1 default: return 0 } } func lessByMinTimeAndMinRef(a, b chunks.Meta) int { - if a.MinTime == b.MinTime { - switch { - case a.Ref < b.Ref: - return -1 - case a.Ref > b.Ref: - return 1 - default: - return 0 - } - } switch { case a.MinTime < b.MinTime: return -1 case a.MinTime > b.MinTime: return 1 + } + + switch { + case a.Ref < b.Ref: + return -1 + case a.Ref > b.Ref: + return 1 default: return 0 }