@@ -9,6 +9,7 @@ pub struct Patch<'se> {
99}
1010
1111impl < ' se > Patch < ' se > {
12+ #[ inline( always) ]
1213 pub fn new ( name : & ' se str , data : & ' se dyn erased_serde:: Serialize ) -> Patch < ' se > {
1314 Patch {
1415 name,
@@ -18,15 +19,18 @@ impl<'se> Patch<'se> {
1819 }
1920 }
2021
22+ #[ inline( always) ]
2123 pub fn init ( & self ) {
2224 self . matched_depth . set ( 0 ) ;
2325 self . parsed . set ( false ) ;
2426 }
2527
28+ #[ inline( always) ]
2629 pub fn get_depth ( & self ) -> usize {
2730 self . name . split ( '/' ) . count ( ) - 1
2831 }
2932
33+ #[ inline( always) ]
3034 pub fn get_depth_path ( & self , x : usize ) -> & ' se str {
3135 if x == 0 {
3236 return "" ;
@@ -36,6 +40,7 @@ impl<'se> Patch<'se> {
3640
3741 // I hope to impl serde::ser::Serializer, but erase_serialize's return value is different from
3842 // normal serialize, so we do this.
43+ #[ inline( always) ]
3944 pub fn serialize ( & self , serializer : & mut Serializer < ' se > ) {
4045 self . parsed . set ( true ) ;
4146 self . data
@@ -49,10 +54,12 @@ pub struct PatchList<'se> {
4954}
5055
5156impl < ' se > PatchList < ' se > {
57+ #[ inline( always) ]
5258 pub fn new ( list : & ' se [ Patch < ' se > ] ) -> PatchList < ' se > {
5359 PatchList { list }
5460 }
5561
62+ #[ inline( always) ]
5663 pub fn step_forward ( & self , name : & ' se str , depth : usize ) -> Option < & ' se Patch < ' se > > {
5764 let mut matched_patch = None ;
5865 self . list . iter ( ) . for_each ( |patch| {
@@ -69,6 +76,7 @@ impl<'se> PatchList<'se> {
6976 matched_patch
7077 }
7178
79+ #[ inline( always) ]
7280 pub fn step_back ( & self , depth : usize ) {
7381 self . list . iter ( ) . for_each ( |patch| {
7482 if patch. matched_depth . get ( ) == depth {
@@ -77,6 +85,7 @@ impl<'se> PatchList<'se> {
7785 } ) ;
7886 }
7987
88+ #[ inline( always) ]
8089 pub fn add_list ( & self , depth : usize ) -> impl Iterator < Item = & ' se Patch < ' se > > + use < ' se > {
8190 self . list . iter ( ) . filter ( move |x| {
8291 x. matched_depth . get ( ) == depth && x. get_depth ( ) == depth + 1 && !x. parsed . get ( )
0 commit comments