fix Revert() bug

This commit is contained in:
Andy Arthur
2022-09-07 17:08:05 -07:00
parent dd42b134d2
commit e95cb86cd6

View File

@@ -92,11 +92,13 @@ func (l *List) Checkpoint() {
// Revert reverts to the last recorded checkpoint.
func (l *List) Revert() {
keepers := l.nodes[1:l.checkpoint]
cp := l.checkpoint
keepers := l.nodes[1:cp]
l.Truncate()
for _, nd := range keepers {
l.Put(nd.key, nd.val)
}
l.checkpoint = cp
}
// Truncate deletes all entries from the list.