Skip to content

Commit

Permalink
perf: minimize assertion calls and reduce overhead (#107)
Browse files Browse the repository at this point in the history
perf: #94

Signed-off-by: lookupman <[email protected]>
  • Loading branch information
dream-kzx authored Jul 14, 2024
1 parent 13b1c27 commit 8c6c219
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions opengemini/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ func (c *client) ShowSeries(database, command string) ([]string, error) {
return []string{}, nil
}
for _, v := range seriesResult[0].Values {
if _, ok := v.(string); !ok {
strV, ok := v.(string)
if !ok {
return series, nil
}
series = append(series, v.(string))
series = append(series, strV)
}
return series, nil
}
13 changes: 7 additions & 6 deletions opengemini/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ func (c *client) showTagSeriesQuery(database, command string) ([]ValuesResult, e
tagSeriesRes.Measurement = res.Name
for _, valRes := range res.Values {
for _, value := range valRes {
if _, ok := value.(string); !ok {
strVal, ok := value.(string)
if !ok {
return tagSeries, nil
}
tagSeriesRes.Values = append(tagSeriesRes.Values, value.(string))
tagSeriesRes.Values = append(tagSeriesRes.Values, strVal)
}
}
tagSeries = append(tagSeries, *tagSeriesRes)
Expand Down Expand Up @@ -143,11 +144,11 @@ func (c *client) showTagFieldQuery(database, command string) ([]ValuesResult, er
if len(valRes) < 2 {
return tagValueResult, nil
}
if _, ok := valRes[0].(string); ok {
tagValue.Name = valRes[0].(string)
if strVal, ok := valRes[0].(string); ok {
tagValue.Name = strVal
}
if _, ok := valRes[1].(string); ok {
tagValue.Value = valRes[1].(string)
if strVal, ok := valRes[1].(string); ok {
tagValue.Value = strVal
}
tagValueRes.Values = append(tagValueRes.Values, *tagValue)
}
Expand Down

0 comments on commit 8c6c219

Please sign in to comment.