io: improve GetVarSize() documentation

This commit is contained in:
Roman Khimov 2019-09-20 19:10:13 +03:00
parent 6dd37dd076
commit d01b7740e2

View file

@ -53,9 +53,10 @@ func getVarStringSize(value string) int {
return getVarIntSize(valueSize) + valueSize return getVarIntSize(valueSize) + valueSize
} }
// GetVarSize return the size om bytes of a variable. This implementation is not exactly like the C# // GetVarSize returns the number of bytes in a serialized variable. It supports ints/uints (estimating
// (reference: GetVarSize<T>(this T[] value), https://github.com/neo-project/neo/blob/master/neo/IO/Helper.cs#L53) as in the C# variable // them using variable-length encoding that is used in NEO), strings, pointers to Serializable structures,
// like Uint160, Uint256 are not supported. // slices and arrays of ints/uints or Serializable structures. It's similar to GetVarSize<T>(this T[] value)
// used in C#, but differs in that it also supports things like Uint160 or Uint256.
func GetVarSize(value interface{}) int { func GetVarSize(value interface{}) int {
v := reflect.ValueOf(value) v := reflect.ValueOf(value)
switch v.Kind() { switch v.Kind() {