Skip to content

Commit

Permalink
Use pointer receivers for some types:
Browse files Browse the repository at this point in the history
- `VaryingDataTypeSlice`'s `String` method
- `VaryingDataType`'s `String` method
- Trie `Node`'s `Copy` method
- pprof `Settings`'s `String` method
- Keep value receivers for VDTs, `common.Hash`, `transaction.priorityQueue`
  • Loading branch information
qdm12 committed Jan 24, 2023
1 parent 97495ab commit 2c3d904
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/pprof/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ type Settings struct {
MutexProfileRate int
}

func (s *Settings) setDefaults() { //skipcq: GO-W1029
func (s *Settings) setDefaults() {
if s.ListeningAddress == "" {
s.ListeningAddress = "localhost:6060"
}
}

func (s Settings) String() string { //skipcq: GO-W1029
func (s *Settings) String() string {
return fmt.Sprintf(
"listening on %s and setting block profile rate to %d, mutex profile rate to %d",
s.ListeningAddress, s.BlockProfileRate, s.MutexProfileRate)
Expand Down
2 changes: 1 addition & 1 deletion internal/trie/node/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type CopySettings struct {
// Copy deep copies the node.
// Setting copyChildren to true will deep copy
// children as well.
func (n *Node) Copy(settings CopySettings) *Node { //skipcq: GO-W1029
func (n *Node) Copy(settings CopySettings) *Node {
cpy := &Node{
Dirty: n.Dirty,
Generation: n.Generation,
Expand Down
10 changes: 5 additions & 5 deletions pkg/scale/varying_data_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type VaryingDataTypeSlice struct {
}

// Add takes variadic parameter values to add VaryingDataTypeValue(s)
func (vdts *VaryingDataTypeSlice) Add(values ...VaryingDataTypeValue) (err error) { //skipcq: GO-W1029
func (vdts *VaryingDataTypeSlice) Add(values ...VaryingDataTypeValue) (err error) {
for _, val := range values {
copied := vdts.VaryingDataType
err = copied.Set(val)
Expand All @@ -34,7 +34,7 @@ func (vdts *VaryingDataTypeSlice) Add(values ...VaryingDataTypeValue) (err error
return
}

func (vdts VaryingDataTypeSlice) String() string { //skipcq: GO-W1029
func (vdts *VaryingDataTypeSlice) String() string {
stringTypes := make([]string, len(vdts.Types))
for i, vdt := range vdts.Types {
stringTypes[i] = vdt.String()
Expand Down Expand Up @@ -65,7 +65,7 @@ type VaryingDataType struct {
}

// Set will set the VaryingDataType value
func (vdt *VaryingDataType) Set(value VaryingDataTypeValue) (err error) { //skipcq: GO-W1029
func (vdt *VaryingDataType) Set(value VaryingDataTypeValue) (err error) {
_, ok := vdt.cache[value.Index()]
if !ok {
err = fmt.Errorf("%w: %v (%T)", ErrUnsupportedVaryingDataTypeValue, value, value)
Expand All @@ -76,14 +76,14 @@ func (vdt *VaryingDataType) Set(value VaryingDataTypeValue) (err error) { //skip
}

// Value returns value stored in vdt
func (vdt *VaryingDataType) Value() (VaryingDataTypeValue, error) { //skipcq: GO-W1029
func (vdt *VaryingDataType) Value() (VaryingDataTypeValue, error) {
if vdt.value == nil {
return nil, ErrVaryingDataTypeNotSet
}
return vdt.value, nil
}

func (vdt VaryingDataType) String() string { //skipcq: GO-W1029
func (vdt *VaryingDataType) String() string {
if vdt.value == nil {
return "VaryingDataType(nil)"
}
Expand Down

0 comments on commit 2c3d904

Please sign in to comment.