From e99a6e69d387b94fc7c19b1a4608d70b23a734f8 Mon Sep 17 00:00:00 2001 From: Suhaha Date: Thu, 19 May 2022 09:26:04 +0800 Subject: [PATCH] chore: make lint happy --- pkg/keyvisual/decorator/tidb.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/keyvisual/decorator/tidb.go b/pkg/keyvisual/decorator/tidb.go index 805e7250f8..dfe087bfe2 100644 --- a/pkg/keyvisual/decorator/tidb.go +++ b/pkg/keyvisual/decorator/tidb.go @@ -82,8 +82,8 @@ func (inOrder *TableInOrder) BuildFromTableMap(m *sync.Map) { // FindOne will find first table detail which id is between [fromId, toId). // Returns nil if not found any -func (inOrder *TableInOrder) FindOne(fromId, toId int64) *tableDetail { - if fromId >= toId { +func (inOrder *TableInOrder) FindOne(fromID, toID int64) *tableDetail { + if fromID >= toID { return nil } @@ -91,22 +91,22 @@ func (inOrder *TableInOrder) FindOne(fromId, toId int64) *tableDetail { defer inOrder.rwMu.RUnlock() tLen := len(inOrder.tables) - var pivot int = tLen / 2 + pivot := tLen / 2 left := 0 right := tLen for pivot > left { - prevId := inOrder.tables[pivot-1].ID + prevID := inOrder.tables[pivot-1].ID id := inOrder.tables[pivot].ID // find approaching id near the fromId // table_1 ------- table_3 ------- table_5 // ^ // search table_2 // approaching result: table_3 - if prevId < fromId && id >= fromId { + if prevID < fromID && id >= fromID { break } - if id < fromId { + if id < fromID { left = pivot } else { right = pivot @@ -115,7 +115,7 @@ func (inOrder *TableInOrder) FindOne(fromId, toId int64) *tableDetail { } id := inOrder.tables[pivot].ID - if id < fromId || id >= toId { + if id < fromID || id >= toID { return nil } @@ -228,9 +228,8 @@ func (e *tidbLabeler) label(startKey, endKey string) (label LabelKey) { label.Labels = append(label.Labels, detail.DB, detail.Name) // can't find the row/index info if the table info was came from a range return - } else { - label.Labels = append(label.Labels, fmt.Sprintf("table_%d", startTableID)) } + label.Labels = append(label.Labels, fmt.Sprintf("table_%d", startTableID)) } if isCommonHandle, rowID := startKeyInfo.RowInfo(); isCommonHandle {