From 9ddccfb89af982dd8d9312b581718d8e43505b10 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Thu, 3 Mar 2022 17:05:07 -0500 Subject: [PATCH] delegate: avoid extra string->int parsing Release justification: low risk improvement Release note: None --- pkg/sql/delegate/show_completions.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/sql/delegate/show_completions.go b/pkg/sql/delegate/show_completions.go index 268b1b345c32..a73575b6b51b 100644 --- a/pkg/sql/delegate/show_completions.go +++ b/pkg/sql/delegate/show_completions.go @@ -14,27 +14,21 @@ import ( "bytes" "fmt" "sort" - "strconv" "strings" "unicode" "github.com/cockroachdb/cockroach/pkg/sql/lexbase" "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" - "github.com/cockroachdb/errors" ) func (d *delegator) delegateShowCompletions(n *tree.ShowCompletions) (tree.Statement, error) { - offsetVal, ok := n.Offset.AsConstantInt() - if !ok { - return nil, errors.Newf("invalid offset %v", n.Offset) - } - offset, err := strconv.Atoi(offsetVal.String()) + offset, err := n.Offset.AsInt64() if err != nil { return nil, err } - completions, err := RunShowCompletions(n.Statement.RawString(), offset) + completions, err := RunShowCompletions(n.Statement.RawString(), int(offset)) if err != nil { return nil, err }