Copilot commented on code in PR #814:
URL:
https://github.com/apache/skywalking-banyandb/pull/814#discussion_r2443372716
##########
banyand/trace/block.go:
##########
@@ -207,16 +207,18 @@ func (b *block) unmarshalTagFromSeqReaders(decoder
*encoding.BytesBlockDecoder,
bigValuePool.Release(bb)
b.resizeTags(len(b.tags))
- // TODO: avoid sorting the tagType map
- keys := make([]string, 0, len(tagType))
- for k := range tagType {
- keys = append(keys, k)
+ b.tags[i].name = name
+ if valueType, ok := tagType[name]; ok {
+ b.tags[i].valueType = valueType
+ tm.name = name
+ tm.valueType = valueType
+ } else {
+ b.tags[i].valueType = pbv1.ValueTypeUnknown
+ for j := range b.tags[i].values {
+ b.tags[i].values[j] = nil
+ }
+ return
}
Review Comment:
[nitpick] The tag name is assigned twice: once to `b.tags[i].name` (line
210) and again to `tm.name` (line 213). Consider setting `tm.name` and
`tm.valueType` before the conditional check, then assign from `tm` to
`b.tags[i]` to reduce duplication and improve maintainability.
```suggestion
tm.name = name
if valueType, ok := tagType[name]; ok {
tm.valueType = valueType
} else {
tm.valueType = pbv1.ValueTypeUnknown
for j := range b.tags[i].values {
b.tags[i].values[j] = nil
}
b.tags[i].name = tm.name
b.tags[i].valueType = tm.valueType
return
}
b.tags[i].name = tm.name
b.tags[i].valueType = tm.valueType
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]