Skip to content

Commit

Permalink
Fix Spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed Apr 13, 2024
1 parent 3f65cb3 commit 979032a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
};

use self::nodes::{
Branch, KeyPosition, KeyPositionAdjecent, Leaf, Node, NodeRef, StoredLeafRef, TrieRoot,
Branch, KeyPosition, KeyPositionAdjacent, Leaf, Node, NodeRef, StoredLeafRef, TrieRoot,
};

pub struct Transaction<S, V> {
Expand Down Expand Up @@ -178,7 +178,7 @@ impl<S: Store<V>, V> Transaction<S, V> {
NodeRef::ModBranch(branch) => match branch.key_position(key_hash) {
KeyPosition::Left => node_ref = &branch.left,
KeyPosition::Right => node_ref = &branch.right,
KeyPosition::Adjecent(_) => return Ok(None),
KeyPosition::Adjacent(_) => return Ok(None),
},
NodeRef::ModLeaf(leaf) => {
if leaf.key_hash == *key_hash {
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<S: Store<V>, V> Transaction<S, V> {
Node::Branch(branch) => match branch.key_position(key_hash) {
KeyPosition::Left => stored_idx = branch.left,
KeyPosition::Right => stored_idx = branch.right,
KeyPosition::Adjecent(_) => return Ok(None),
KeyPosition::Adjacent(_) => return Ok(None),
},
Node::Leaf(leaf) => {
if leaf.key_hash == *key_hash {
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<S: Store<V>, V> Transaction<S, V> {
node_ref = &mut branch.right;
continue;
}
KeyPosition::Adjecent(pos) => {
KeyPosition::Adjacent(pos) => {
branch.new_adjacent_leaf(
pos,
Box::new(Leaf {
Expand Down Expand Up @@ -349,11 +349,11 @@ impl<S: Store<V>, V: PortableHash + Clone> Transaction<S, V> {
/// We match the standard library's `Entry` API for the most part.
///
/// Note: Use of `entry` renders the trie path even if the entry is not modified.
/// This will incures allocations, now and unessisary rehashing later when calculating the root hash.
/// This incurs allocations, now and unnecessary rehashing later when calculating the root hash.
/// For this reason you should prefer `get` if you have a high probability of not modifying the entry.
#[inline]
pub fn entry<'txn>(&'txn mut self, key_hash: &KeyHash) -> Result<Entry<'txn, V>, TrieError> {
let mut key_position = KeyPositionAdjecent::PrefixOfWord(usize::MAX);
let mut key_position = KeyPositionAdjacent::PrefixOfWord(usize::MAX);

match self.current_root {
TrieRoot::Empty => Ok(Entry::VacantEmptyTrie(VacantEntryEmptyTrie {
Expand All @@ -367,7 +367,7 @@ impl<S: Store<V>, V: PortableHash + Clone> Transaction<S, V> {
NodeRef::ModBranch(branch) => match branch.key_position(key_hash) {
KeyPosition::Left => false,
KeyPosition::Right => true,
KeyPosition::Adjecent(pos) => {
KeyPosition::Adjacent(pos) => {
key_position = pos;
break;
}
Expand Down Expand Up @@ -411,11 +411,11 @@ impl<S: Store<V>, V: PortableHash + Clone> Transaction<S, V> {
// This convoluted return makes the borrow checker happy.
if let NodeRef::ModLeaf(leaf) = &*node_ref {
if leaf.key_hash != *key_hash {
// This is bassically a logical null
// This is a logical null
// TODO we should break VacantEntry into two types VacantEntryBranch and VacantEntryLeaf
debug_assert_eq!(
key_position,
KeyPositionAdjecent::PrefixOfWord(usize::MAX)
KeyPositionAdjacent::PrefixOfWord(usize::MAX)
);

return Ok(Entry::Vacant(VacantEntry {
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a, V> OccupiedEntry<'a, V> {
pub struct VacantEntry<'a, V> {
parent: &'a mut NodeRef<V>,
key_hash: KeyHash,
key_position: KeyPositionAdjecent,
key_position: KeyPositionAdjacent,
}

impl<'a, V> VacantEntry<'a, V> {
Expand Down
22 changes: 11 additions & 11 deletions src/transaction/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ impl<NR> fmt::Debug for Branch<NR> {

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum KeyPosition {
Adjecent(KeyPositionAdjecent),
Adjacent(KeyPositionAdjacent),
Right,
Left,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum KeyPositionAdjecent {
pub enum KeyPositionAdjacent {
/// The delta bit occurs before the existing branch's discriminant bit in the same word.
/// `branch.mask.word_idx() == PrefixOfWord(word_idx)`.
PrefixOfWord(usize),
Expand Down Expand Up @@ -303,15 +303,15 @@ impl<NR> Branch<NR> {
.find(|(branch_word, (_, key_word))| branch_word != key_word);

if let Some((_, (idx, _))) = prefix_diff {
return KeyPosition::Adjecent(KeyPositionAdjecent::PrefixVec(idx));
return KeyPosition::Adjacent(KeyPositionAdjacent::PrefixVec(idx));
}

// If sub wraps around to the last word, the prior word is 0.
let prior_word_idx = word_idx.wrapping_sub(1);
let prior_word = key_hash.0.get(prior_word_idx).unwrap_or(&0);

if self.prior_word != *prior_word {
return KeyPosition::Adjecent(KeyPositionAdjecent::PriorWord(prior_word_idx));
return KeyPosition::Adjacent(KeyPositionAdjacent::PriorWord(prior_word_idx));
}

let hash_segment = key_hash.0[word_idx];
Expand All @@ -321,7 +321,7 @@ impl<NR> Branch<NR> {
} else if self.mask.is_right_descendant(hash_segment) {
KeyPosition::Right
} else {
KeyPosition::Adjecent(KeyPositionAdjecent::PrefixOfWord(word_idx))
KeyPosition::Adjacent(KeyPositionAdjacent::PrefixOfWord(word_idx))
}
}

Expand Down Expand Up @@ -369,7 +369,7 @@ impl<V> Branch<NodeRef<V>> {
#[inline]
pub(crate) fn new_adjacent_leaf(
self: &mut Box<Self>,
key_position: KeyPositionAdjecent,
key_position: KeyPositionAdjacent,
leaf: Box<Leaf<V>>,
) {
self.new_adjacent_leaf_ret(key_position, leaf);
Expand All @@ -378,15 +378,15 @@ impl<V> Branch<NodeRef<V>> {
/// Store a new leaf adjacent to an existing branch.
/// New branch will be stored in the old branch's Box.
/// The old branch will be moved to a new Box, under the new branch.
// inline(always) is used to increace the odds of the compiler removing the return when unused.
// inline(always) is used to increase the odds of the compiler removing the return when unused.
#[inline(always)]
pub(crate) fn new_adjacent_leaf_ret<'a>(
self: &'a mut Box<Self>,
key_position: KeyPositionAdjecent,
key_position: KeyPositionAdjacent,
leaf: Box<Leaf<V>>,
) -> &'a mut Leaf<V> {
let (mask, prior_word, prefix, leaf_word) = match key_position {
KeyPositionAdjecent::PrefixOfWord(word_idx) => {
KeyPositionAdjacent::PrefixOfWord(word_idx) => {
debug_assert_eq!(self.mask.word_idx(), word_idx);

let branch_word = self.mask.left_prefix;
Expand Down Expand Up @@ -414,7 +414,7 @@ impl<V> Branch<NodeRef<V>> {
leaf_word,
)
}
KeyPositionAdjecent::PriorWord(word_idx) => {
KeyPositionAdjacent::PriorWord(word_idx) => {
debug_assert_eq!(word_idx, self.mask.word_idx() - 1);

let branch_word = self.prior_word;
Expand All @@ -429,7 +429,7 @@ impl<V> Branch<NodeRef<V>> {

(mask, *prior_word, mem::take(&mut self.prefix), leaf_word)
}
KeyPositionAdjecent::PrefixVec(word_idx) => {
KeyPositionAdjacent::PrefixVec(word_idx) => {
debug_assert!(self.mask.word_idx() - word_idx >= 2);
debug_assert!(!self.prefix.is_empty());

Expand Down

0 comments on commit 979032a

Please sign in to comment.