7979use crate :: {
8080 morphisms:: Catamorphism ,
8181 utils:: { BitMask , ByteMask , find_prefix_overlap} ,
82+ timed_span:: timed_span,
8283 zipper:: {
8384 Zipper , ZipperValues , ZipperForking , ZipperAbsolutePath , ZipperIteration ,
8485 ZipperMoving , ZipperPathBuffer , ZipperReadOnlyValues ,
@@ -1657,10 +1658,13 @@ impl<'tree, Storage> ZipperMoving for ACTZipper<'tree, Storage>
16571658where Storage : AsRef < [ u8 ] >
16581659{
16591660 /// Returns `true` if the zipper cannot ascend further, otherwise returns `false`
1660- fn at_root ( & self ) -> bool { self . path . len ( ) <= self . origin_depth }
1661+ fn at_root ( & self ) -> bool {
1662+ self . path . len ( ) <= self . origin_depth
1663+ }
16611664
16621665 /// Resets the zipper's focus back to the root
16631666 fn reset ( & mut self ) {
1667+ timed_span ! ( Reset ) ;
16641668 // self.ascend(self.path.len() - self.origin_depth);
16651669 self . path . truncate ( self . origin_depth ) ;
16661670 self . cur_node = self . tree . get_node ( self . stack [ 0 ] . node_id ) . 0 ;
@@ -1675,6 +1679,7 @@ where Storage: AsRef<[u8]>
16751679 ///
16761680 /// WARNING: This is not a cheap method. It may have an order-N cost
16771681 fn val_count ( & self ) -> usize {
1682+ timed_span ! ( ValueCount ) ;
16781683 let mut zipper = self . clone ( ) ;
16791684 zipper. reset ( ) ;
16801685 let mut count = 0 ;
@@ -1692,6 +1697,7 @@ where Storage: AsRef<[u8]>
16921697 /// Returns `true` if the zipper points to an existing path within the tree, otherwise `false`. The
16931698 /// zipper's location will be updated, regardless of whether or not the path exists within the tree.
16941699 fn descend_to < P : AsRef < [ u8 ] > > ( & mut self , path : P ) -> bool {
1700+ timed_span ! ( DescendTo ) ;
16951701 let path = path. as_ref ( ) ;
16961702 let depth = path. len ( ) ;
16971703 let descended = self . descend_to_existing ( path) ;
@@ -1711,6 +1717,7 @@ where Storage: AsRef<[u8]>
17111717 /// existing path after this method returns, unless the method was called with the focus on a
17121718 /// non-existent path.
17131719 fn descend_to_existing < P : AsRef < [ u8 ] > > ( & mut self , path : P ) -> usize {
1720+ timed_span ! ( DescendToExisting ) ;
17141721 self . descend_cond ( path. as_ref ( ) , false )
17151722 }
17161723
@@ -1722,12 +1729,14 @@ where Storage: AsRef<[u8]>
17221729 /// If the focus is already on a value, this method will descend to the *next* value along
17231730 /// the path.
17241731 fn descend_to_value < K : AsRef < [ u8 ] > > ( & mut self , path : K ) -> usize {
1732+ timed_span ! ( DescendToValue ) ;
17251733 self . descend_cond ( path. as_ref ( ) , true )
17261734 }
17271735
17281736 /// Moves the zipper one byte deeper into the trie. Identical in effect to [descend_to](Self::descend_to)
17291737 /// with a 1-byte key argument
17301738 fn descend_to_byte ( & mut self , k : u8 ) -> bool {
1739+ timed_span ! ( DescendToByte ) ;
17311740 self . descend_to ( & [ k] )
17321741 }
17331742
@@ -1739,6 +1748,7 @@ where Storage: AsRef<[u8]>
17391748 /// to the trie. This method should only be used as part of a directed traversal operation, but
17401749 /// index-based paths may not be stored as locations within the trie.
17411750 fn descend_indexed_branch ( & mut self , idx : usize ) -> bool {
1751+ timed_span ! ( DescendIndexedBranch ) ;
17421752 if self . invalid > 0 {
17431753 return false ;
17441754 }
@@ -1793,12 +1803,14 @@ where Storage: AsRef<[u8]>
17931803 /// NOTE: This method should have identical behavior to passing `0` to [descend_indexed_branch](ZipperMoving::descend_indexed_branch),
17941804 /// although with less overhead
17951805 fn descend_first_byte ( & mut self ) -> bool {
1806+ timed_span ! ( DescendFirstByte ) ;
17961807 self . descend_indexed_branch ( 0 )
17971808 }
17981809
17991810 /// Descends the zipper's focus until a branch or a value is encountered. Returns `true` if the focus
18001811 /// moved otherwise returns `false`
18011812 fn descend_until ( & mut self ) -> bool {
1813+ timed_span ! ( DescendUntil ) ;
18021814 self . trace_pos ( ) ;
18031815 let mut descended = false ;
18041816 ' descend: while self . child_count ( ) == 1 {
@@ -1849,6 +1861,7 @@ where Storage: AsRef<[u8]>
18491861 /// If the root is fewer than `n` steps from the zipper's position, then this method will stop at
18501862 /// the root and return `false`
18511863 fn ascend ( & mut self , mut steps : usize ) -> bool {
1864+ timed_span ! ( Ascend ) ;
18521865 self . trace_pos ( ) ;
18531866 if !self . ascend_invalid ( Some ( steps) ) {
18541867 return false ;
@@ -1875,29 +1888,34 @@ where Storage: AsRef<[u8]>
18751888
18761889 /// Ascends the zipper up a single byte. Equivalent to passing `1` to [ascend](Self::ascend)
18771890 fn ascend_byte ( & mut self ) -> bool {
1891+ timed_span ! ( AscendByte ) ;
18781892 self . ascend ( 1 )
18791893 }
18801894
18811895 /// Ascends the zipper to the nearest upstream branch point or value. Returns `true` if the zipper
18821896 /// focus moved upwards, otherwise returns `false` if the zipper was already at the root
18831897 fn ascend_until ( & mut self ) -> bool {
1898+ timed_span ! ( AscendUntil ) ;
18841899 self . ascend_to_branch ( true )
18851900 }
18861901
18871902 /// Ascends the zipper to the nearest upstream branch point, skipping over values along the way. Returns
18881903 /// `true` if the zipper focus moved upwards, otherwise returns `false` if the zipper was already at the
18891904 /// root
18901905 fn ascend_until_branch ( & mut self ) -> bool {
1906+ timed_span ! ( AscendUntilBranch ) ;
18911907 self . ascend_to_branch ( false )
18921908 }
18931909
18941910 #[ inline]
18951911 fn to_next_sibling_byte ( & mut self ) -> bool {
1912+ timed_span ! ( ToNextSiblingByte ) ;
18961913 self . to_sibling ( true )
18971914 }
18981915
18991916 #[ inline]
19001917 fn to_prev_sibling_byte ( & mut self ) -> bool {
1918+ timed_span ! ( ToPrevSiblingByte ) ;
19011919 self . to_sibling ( false )
19021920 }
19031921
@@ -1913,6 +1931,7 @@ where Storage: AsRef<[u8]>
19131931 ///
19141932 /// Returns a reference to the value or `None` if the zipper has encountered the root.
19151933 fn to_next_val ( & mut self ) -> bool {
1934+ timed_span ! ( ToNextVal ) ;
19161935 while self . to_next_step ( ) {
19171936 if self . is_value ( ) {
19181937 return true ;
@@ -1932,6 +1951,7 @@ where Storage: AsRef<[u8]>
19321951 ///
19331952 /// See: [to_next_k_path](ZipperIteration::to_next_k_path)
19341953 fn descend_first_k_path ( & mut self , k : usize ) -> bool {
1954+ timed_span ! ( DescendFirstKPath ) ;
19351955 for ii in 0 ..k {
19361956 if !self . descend_first_byte ( ) {
19371957 self . ascend ( ii) ;
@@ -1953,6 +1973,7 @@ where Storage: AsRef<[u8]>
19531973 ///
19541974 /// See: [descend_first_k_path](ZipperIteration::descend_first_k_path)
19551975 fn to_next_k_path ( & mut self , k : usize ) -> bool {
1976+ timed_span ! ( ToNextKPath ) ;
19561977 let mut depth = k;
19571978 ' outer: loop {
19581979 while depth > 0 && self . child_count ( ) <= 1 {
0 commit comments