mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Use usize for unification, not u32
This commit is contained in:
parent
960d42c33d
commit
acc0933c65
3 changed files with 14 additions and 14 deletions
|
@ -29,7 +29,7 @@ pub trait UnificationStore:
|
|||
|
||||
fn values_since_snapshot(&self, snapshot: &Self::Snapshot) -> Range<usize>;
|
||||
|
||||
fn reset_unifications(&mut self, value: impl FnMut(u32) -> VarValue<Self::Key>);
|
||||
fn reset_unifications(&mut self, value: impl FnMut(usize) -> VarValue<Self::Key>);
|
||||
|
||||
fn len(&self) -> usize;
|
||||
|
||||
|
@ -90,8 +90,8 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn reset_unifications(&mut self, mut value: impl FnMut(u32) -> VarValue<Self::Key>) {
|
||||
self.values.set_all(|i| value(i as u32));
|
||||
fn reset_unifications(&mut self, mut value: impl FnMut(usize) -> VarValue<Self::Key>) {
|
||||
self.values.set_all(|i| value(i));
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
|
@ -182,12 +182,12 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn reset_unifications(&mut self, mut value: impl FnMut(u32) -> VarValue<Self::Key>) {
|
||||
fn reset_unifications(&mut self, mut value: impl FnMut(usize) -> VarValue<Self::Key>) {
|
||||
// Without extending dogged, there isn't obviously a more
|
||||
// efficient way to do this. But it's pretty dumb. Maybe
|
||||
// dogged needs a `map`. [NOTE: revisit in light of replacing dogged with im_rc!]
|
||||
for i in 0..self.values.len() {
|
||||
self.values[i] = value(i as u32);
|
||||
self.values[i] = value(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,9 @@ pub use self::backing_vec::Persistent;
|
|||
pub trait UnifyKey: Copy + Clone + Debug + PartialEq {
|
||||
type Value: Clone + Debug;
|
||||
|
||||
fn index(&self) -> u32;
|
||||
fn index(&self) -> usize;
|
||||
|
||||
fn from_index(u: u32) -> Self;
|
||||
fn from_index(u: usize) -> Self;
|
||||
|
||||
fn tag() -> &'static str;
|
||||
|
||||
|
@ -215,7 +215,7 @@ impl<S: UnificationStore> UnificationTable<S> {
|
|||
/// Creates a fresh key with the given value.
|
||||
pub fn new_key(&mut self, value: S::Value) -> S::Key {
|
||||
let len = self.values.len();
|
||||
let key: S::Key = UnifyKey::from_index(len as u32);
|
||||
let key: S::Key = UnifyKey::from_index(len);
|
||||
self.values.push(VarValue::new_var(key, value));
|
||||
debug!("{}: created new key: {:?}", S::tag(), key);
|
||||
key
|
||||
|
@ -232,7 +232,7 @@ impl<S: UnificationStore> UnificationTable<S> {
|
|||
/// the closure.
|
||||
pub fn reset_unifications(&mut self, mut value: impl FnMut(S::Key) -> S::Value) {
|
||||
self.values.reset_unifications(|i| {
|
||||
let key = UnifyKey::from_index(i as u32);
|
||||
let key = UnifyKey::from_index(i);
|
||||
let value = value(key);
|
||||
VarValue::new_var(key, value)
|
||||
});
|
||||
|
@ -251,7 +251,7 @@ impl<S: UnificationStore> UnificationTable<S> {
|
|||
/// Returns the keys of all variables created since the `snapshot`.
|
||||
pub fn vars_since_snapshot(&self, snapshot: &Snapshot<S>) -> Range<S::Key> {
|
||||
let range = self.values.values_since_snapshot(&snapshot.snapshot);
|
||||
S::Key::from_index(range.start as u32)..S::Key::from_index(range.end as u32)
|
||||
S::Key::from_index(range.start)..S::Key::from_index(range.end)
|
||||
}
|
||||
|
||||
/// Obtains the current value for a particular key.
|
||||
|
|
|
@ -9,10 +9,10 @@ pub struct Subs {
|
|||
}
|
||||
|
||||
#[derive(Copy, PartialEq, Eq, Clone, Hash)]
|
||||
pub struct Variable(u32);
|
||||
pub struct Variable(usize);
|
||||
|
||||
impl Variable {
|
||||
pub fn new_for_testing_only(num: u32) -> Self {
|
||||
pub fn new_for_testing_only(num: usize) -> Self {
|
||||
// This is a hack that should only ever be used for testing!
|
||||
Variable(num)
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ impl fmt::Debug for Variable {
|
|||
impl UnifyKey for Variable {
|
||||
type Value = Descriptor;
|
||||
|
||||
fn index(&self) -> u32 {
|
||||
fn index(&self) -> usize {
|
||||
self.0
|
||||
}
|
||||
|
||||
fn from_index(index: u32) -> Self {
|
||||
fn from_index(index: usize) -> Self {
|
||||
Variable(index)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue