File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -655,17 +655,18 @@ func (ml MapList) MarshalAmino() (MapListImage, error) {
655655}
656656
657657func (ml * MapList ) UnmarshalAmino (mlimg MapListImage ) error {
658- for _ , item := range mlimg .List {
659- if ml . Head == nil {
658+ for i , item := range mlimg .List {
659+ if i == 0 {
660660 item .Prev = nil
661661 ml .Head = item
662662 ml .Tail = item
663+ ml .Size = 1
663664 } else {
664665 item .Prev = ml .Tail
665666 ml .Tail .Next = item
666667 ml .Tail = item
668+ ml .Size ++
667669 }
668- ml .Size ++
669670 }
670671 return nil
671672}
@@ -682,16 +683,20 @@ func (ml *MapList) Append(alloc *Allocator, key TypedValue) *MapListItem {
682683 item .Prev = nil
683684 ml .Head = item
684685 ml .Tail = item
686+ ml .Size = 1
685687 } else {
686688 item .Prev = ml .Tail
687689 ml .Tail .Next = item
688690 ml .Tail = item
691+ ml .Size ++
689692 }
690- ml .Size ++
691693 return item
692694}
693695
694696func (ml * MapList ) Remove (mli * MapListItem ) {
697+ if ml .Size == 0 {
698+ return
699+ }
695700 prev , next := mli .Prev , mli .Next
696701 if prev == nil {
697702 ml .Head = next
You can’t perform that action at this time.
0 commit comments