Skip to content

Modify ValStr()/ValBAry() and SetValStr()/SetValBAry() to fetch and return string types instead of *string and other cleanups

Final Release Note

Description

This was an early (in the project) decision when we were less familiar with Go and more familiar with C. We thought it would perform better but have since come to realize passing and returning the addresses of strings and slices is not the Go way and the performance difference is negligible. This change fixes that by changing the *string parameter or return value to the regular string type like every other Go call uses. So the function signatures change from:

func (buft *BufferT) ValBAry(tptoken uint64, errstr *BufferT) (*[]byte, error)
func (buft *BufferT) ValStr(tptoken uint64, errstr *BufferT) (*string, error)
func (buft *BufferT) SetValBAry(tptoken uint64, errstr *BufferT, value *[]byte) error
func (buft *BufferT) SetValStr(tptoken uint64, errstr *BufferT, value *string) error
func (buftary *BufferTArray) ValBAry(tptoken uint64, errstr *BufferT, idx uint32) (*[]byte, error)
func (buftary *BufferTArray) ValStr(tptoken uint64, errstr *BufferT, idx uint32) (*string, error)
func (buftary *BufferTArray) SetValBAry(tptoken uint64, errstr *BufferT, idx uint32, value *[]byte) error
func (buftary *BufferTArray) SetValStr(tptoken uint64, errstr *BufferT, idx uint32, value *string) error

To:

func (buft *BufferT) ValBAry(tptoken uint64, errstr *BufferT) ([]byte, error)
func (buft *BufferT) ValStr(tptoken uint64, errstr *BufferT) (string, error)
func (buft *BufferT) SetValBAry(tptoken uint64, errstr *BufferT, value []byte) error
func (buft *BufferT) SetValStr(tptoken uint64, errstr *BufferT, value string) error
func (buftary *BufferTArray) ValBAry(tptoken uint64, errstr *BufferT, idx uint32) ([]byte, error)
func (buftary *BufferTArray) ValStr(tptoken uint64, errstr *BufferT, idx uint32) (string, error)
func (buftary *BufferTArray) SetValBAry(tptoken uint64, errstr *BufferT, idx uint32, value []byte) error
func (buftary *BufferTArray) SetValStr(tptoken uint64, errstr *BufferT, idx uint32, value string) error

Note this change makes the SetValStrLit() routines superfluous so they should all be changed to SetValStr() calls (no change needed for parms in this case).

This change also has a number of cleanups, minor robustness fixes and general cleaning for a production release.

Draft Release Note

Several functions that had string or byte array parameters or return values passed or returned by address now pass and return by value (e.g. *string became just string and *[]byte became just []byte). The functions changed are the following (along with their new signatures):

func (buft *BufferT) ValBAry(tptoken uint64, errstr *BufferT) ([]byte, error)
func (buft *BufferT) ValStr(tptoken uint64, errstr *BufferT) (string, error)
func (buft *BufferT) SetValBAry(tptoken uint64, errstr *BufferT, value []byte) error
func (buft *BufferT) SetValStr(tptoken uint64, errstr *BufferT, value string) error
func (buftary *BufferTArray) ValBAry(tptoken uint64, errstr *BufferT, idx uint32) ([]byte, error)
func (buftary *BufferTArray) ValStr(tptoken uint64, errstr *BufferT, idx uint32) (string, error)
func (buftary *BufferTArray) SetValBAry(tptoken uint64, errstr *BufferT, idx uint32, value []byte) error
func (buftary *BufferTArray) SetValStr(tptoken uint64, errstr *BufferT, idx uint32, value string) error
Edited by Steven Estes