uint256 icon indicating copy to clipboard operation
uint256 copied to clipboard

Use value receiver for String()

Open kaber2 opened this issue 1 year ago • 0 comments

I often embed uint256.Int types directly into a struct to avoid the overhead of memory allocation, GC, the pointer memory storage and associated cache misses when following the pointers. When printing such a struct using %v however, the Ints are displayed as an array of their uint64 values.

Can we change the String() method to a value receiver instead? For values of type *T, the methods of T are within its method set, so this would work for both *uint256.Int and uint256.Int.

kaber2 avatar Aug 17 '24 10:08 kaber2