Skip to content

Commit

Permalink
Refactor to use storeSlab in OrderedMap.SetType()
Browse files Browse the repository at this point in the history
  • Loading branch information
fxamacker committed Mar 8, 2024
1 parent 57de859 commit 95dad1c
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5501,30 +5501,15 @@ func (m *OrderedMap) SetType(typeInfo TypeInfo) error {

if m.Inlined() {
// Map is inlined.
// Notify parent container so parent slab is saved in storage with updated TypeInfo of inlined array.
found, err := m.parentUpdater()
if err != nil {
return err
}
if !found {
m.parentUpdater = nil
}

return nil
// Notify parent container so parent slab is saved in storage with updated TypeInfo of inlined array.
return m.notifyParentIfNeeded()
}

// Map is standalone.

slabID := m.SlabID()

// Store modified root slab in storage since typeInfo is part of extraData stored in root slab.
err := m.Storage.Store(slabID, m.root)
if err != nil {
// Wrap err as external error (if needed) because err is returned by SlabStorage interface.
return wrapErrorfAsExternalErrorIfNeeded(err, fmt.Sprintf("failed to store slab %s", slabID))
}

return nil
return storeSlab(m.Storage, m.root)
}

func (m *OrderedMap) String() string {
Expand Down

0 comments on commit 95dad1c

Please sign in to comment.