[#145] sdk/object: Refactor logic of field setters

In previous implementation RawObject constructor initialized internal v2
Object structure recursively so that further you can directly set the values
of nested fields. This caused the object created by constructor New to be
different from the object created from the empty object v2.

Remove recursive initialization of v2 Object from New and NewRaw
constructors. Make setters to initialize nested structures on demand.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-09-16 14:16:58 +03:00 committed by Stanislav Bogatyrev
parent 052a4a97dc
commit 1ac6f2eeeb
3 changed files with 61 additions and 55 deletions

View file

@ -25,7 +25,7 @@ func NewRawFromV2(oV2 *object.Object) *RawObject {
//
// Works similar as NewRawFromV2(new(Object)).
func NewRaw() *RawObject {
return NewRawFromV2(initObjectRecursive())
return NewRawFromV2(new(object.Object))
}
// Object returns read-only object instance.