Skip to content

Commit 69b3d20

Browse files
committed
Rename Snapshot::length to undo_len
1 parent b37bb32 commit 69b3d20

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/snapshot_vec.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<D> fmt::Debug for SnapshotVec<D>
6161
// Snapshots are tokens that should be created/consumed linearly.
6262
pub struct Snapshot {
6363
// Length of the undo log at the time the snapshot was taken.
64-
pub(crate) length: usize,
64+
undo_len: usize,
6565
}
6666

6767
pub trait SnapshotVecDelegate {
@@ -176,24 +176,27 @@ impl<D: SnapshotVecDelegate> SnapshotVec<D> {
176176
let length = self.undo_log.len();
177177
self.num_open_snapshots += 1;
178178
Snapshot { length: length }
179+
Snapshot {
180+
undo_len: self.undo_log.len(),
181+
}
179182
}
180183

181184
pub fn actions_since_snapshot(&self, snapshot: &Snapshot) -> &[UndoLog<D>] {
182-
&self.undo_log[snapshot.length..]
185+
&self.undo_log[snapshot.undo_len..]
183186
}
184187

185188
fn assert_open_snapshot(&self, snapshot: &Snapshot) {
186189
// Failures here may indicate a failure to follow a stack discipline.
187-
assert!(self.undo_log.len() >= snapshot.length);
190+
assert!(self.undo_log.len() >= snapshot.undo_len);
188191
assert!(self.num_open_snapshots > 0);
189192
}
190193

191194
pub fn rollback_to(&mut self, snapshot: Snapshot) {
192-
debug!("rollback_to({})", snapshot.length);
195+
debug!("rollback_to({})", snapshot.undo_len);
193196

194197
self.assert_open_snapshot(&snapshot);
195198

196-
while self.undo_log.len() > snapshot.length {
199+
while self.undo_log.len() > snapshot.undo_len {
197200
match self.undo_log.pop().unwrap() {
198201
NewElem(i) => {
199202
self.values.pop();
@@ -216,15 +219,15 @@ impl<D: SnapshotVecDelegate> SnapshotVec<D> {
216219
/// Commits all changes since the last snapshot. Of course, they
217220
/// can still be undone if there is a snapshot further out.
218221
pub fn commit(&mut self, snapshot: Snapshot) {
219-
debug!("commit({})", snapshot.length);
222+
debug!("commit({})", snapshot.undo_len);
220223

221224
self.assert_open_snapshot(&snapshot);
222225

223226
if self.num_open_snapshots == 1 {
224227
// The root snapshot. It's safe to clear the undo log because
225228
// there's no snapshot further out that we might need to roll back
226229
// to.
227-
assert!(snapshot.length == 0);
230+
assert!(snapshot.undo_len == 0);
228231
self.undo_log.clear();
229232
}
230233

0 commit comments

Comments
 (0)