Skip to content

Commit e7ad85c

Browse files
committed
Remove Measurable
1 parent 32da441 commit e7ad85c

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

src/unify/backing_vec.rs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,31 @@ use super::{VarValue, UnifyKey, UnifyValue};
1010
#[allow(type_alias_bounds)]
1111
type Key<S: UnificationStore> = <S as UnificationStore>::Key;
1212

13-
pub trait Measurable {
14-
fn len(&self) -> usize;
15-
}
16-
1713
/// Largely internal trait implemented by the unification table
1814
/// backing store types. The most common such type is `InPlace`,
1915
/// which indicates a standard, mutable unification table.
2016
pub trait UnificationStore:
21-
ops::Index<usize, Output = VarValue<Key<Self>>> + Measurable + Clone + Default
17+
ops::Index<usize, Output = VarValue<Key<Self>>> + Clone + Default
2218
{
2319
type Key: UnifyKey<Value = Self::Value>;
2420
type Value: UnifyValue;
25-
type Snapshot: Measurable;
21+
type Snapshot;
2622

2723
fn start_snapshot(&mut self) -> Self::Snapshot;
2824

2925
fn rollback_to(&mut self, snapshot: Self::Snapshot);
3026

3127
fn commit(&mut self, snapshot: Self::Snapshot);
3228

33-
fn values_since_snapshot(&self, snapshot: &Self::Snapshot) -> Range<usize> {
34-
snapshot.len()..self.len()
35-
}
29+
fn values_since_snapshot(&self, snapshot: &Self::Snapshot) -> Range<usize>;
3630

3731
fn reset_unifications(
3832
&mut self,
3933
value: impl FnMut(u32) -> VarValue<Self::Key>,
4034
);
4135

36+
fn len(&self) -> usize;
37+
4238
fn push(&mut self, value: VarValue<Self::Key>);
4339

4440
fn reserve(&mut self, num_new_values: usize);
@@ -65,20 +61,6 @@ impl<K: UnifyKey> Default for InPlace<K> {
6561
}
6662
}
6763

68-
impl Measurable for sv::Snapshot {
69-
#[inline]
70-
fn len(&self) -> usize {
71-
self.length
72-
}
73-
}
74-
75-
impl<K: UnifyKey> Measurable for InPlace<K> {
76-
#[inline]
77-
fn len(&self) -> usize {
78-
self.values.len()
79-
}
80-
}
81-
8264
impl<K: UnifyKey> UnificationStore for InPlace<K> {
8365
type Key = K;
8466
type Value = K::Value;
@@ -99,6 +81,11 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
9981
self.values.commit(snapshot);
10082
}
10183

84+
#[inline]
85+
fn values_since_snapshot(&self, snapshot: &Self::Snapshot) -> Range<usize> {
86+
snapshot.value_count..self.len()
87+
}
88+
10289
#[inline]
10390
fn reset_unifications(
10491
&mut self,
@@ -107,6 +94,10 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
10794
self.values.set_all(|i| value(i as u32));
10895
}
10996

97+
fn len(&self) -> usize {
98+
self.values.len()
99+
}
100+
110101
#[inline]
111102
fn push(&mut self, value: VarValue<Self::Key>) {
112103
self.values.push(value);
@@ -158,14 +149,6 @@ impl<K: UnifyKey> Default for Persistent<K> {
158149
}
159150
}
160151

161-
#[cfg(feature = "persistent")]
162-
impl<K: UnifyKey> Measurable for Persistent<K> {
163-
#[inline]
164-
fn len(&self) -> usize {
165-
self.values.len()
166-
}
167-
}
168-
169152
#[cfg(feature = "persistent")]
170153
impl<K: UnifyKey> UnificationStore for Persistent<K> {
171154
type Key = K;
@@ -183,7 +166,11 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
183166
}
184167

185168
#[inline]
186-
fn commit(&mut self, _snapshot: Self::Snapshot) {
169+
fn commit(&mut self, _snapshot: Self::Snapshot) {}
170+
171+
#[inline]
172+
fn values_since_snapshot(&self, snapshot: &Self::Snapshot) -> Range<usize> {
173+
snapshot.len()..self.len()
187174
}
188175

189176
#[inline]
@@ -199,6 +186,10 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
199186
}
200187
}
201188

189+
fn len(&self) -> usize {
190+
self.values.len()
191+
}
192+
202193
#[inline]
203194
fn push(&mut self, value: VarValue<Self::Key>) {
204195
self.values.push(value);

0 commit comments

Comments
 (0)