Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kanishkatn committed Oct 25, 2023
1 parent 5a60b6f commit 23b27bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 3 additions & 8 deletions pkg/scale/btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ package scale

import (
"fmt"
"golang.org/x/exp/constraints"
"reflect"

"github.com/tidwall/btree"
)

type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
~float32 | ~float64 | ~string
}

type BTreeCodec interface {
Encode(es *encodeState) error
Decode(ds *decodeState, dstv reflect.Value) error
Expand Down Expand Up @@ -103,7 +98,7 @@ func NewBTree[T any](comparator func(a, b any) bool) *BTree {
}

// BTreeMap is a wrapper around tidwall/btree.Map
type BTreeMap[K Ordered, V any] struct {
type BTreeMap[K constraints.Ordered, V any] struct {
*btree.Map[K, V]
Degree int
}
Expand Down Expand Up @@ -180,7 +175,7 @@ func (btm *BTreeMap[K, V]) Copy() BTreeMap[K, V] {
}

// NewBTreeMap creates a new BTreeMap with the given degree.
func NewBTreeMap[K Ordered, V any](degree int) *BTreeMap[K, V] {
func NewBTreeMap[K constraints.Ordered, V any](degree int) *BTreeMap[K, V] {
return &BTreeMap[K, V]{
Map: btree.NewMap[K, V](degree),
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/scale/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ func (ds *decodeState) unmarshal(dstv reflect.Value) (err error) {
err = ds.decodeVaryingDataType(dstv)
case VaryingDataTypeSlice:
err = ds.decodeVaryingDataTypeSlice(dstv)
case BTree:
err = ds.decodeBTree(dstv)
default:
t := reflect.TypeOf(in)
switch t.Kind() {
Expand Down

0 comments on commit 23b27bc

Please sign in to comment.