@@ -21,7 +21,6 @@ pub struct Cursor<'a> {
2121pub ( crate ) const EOF_CHAR : char = '\0' ;
2222
2323impl < ' a > Cursor < ' a > {
24- #[ inline]
2524 pub fn new ( input : & ' a str , frontmatter_allowed : FrontmatterAllowed ) -> Cursor < ' a > {
2625 Cursor {
2726 len_remaining : input. len ( ) ,
@@ -32,7 +31,6 @@ impl<'a> Cursor<'a> {
3231 }
3332 }
3433
35- #[ inline]
3634 pub fn as_str ( & self ) -> & ' a str {
3735 self . chars . as_str ( )
3836 }
@@ -55,14 +53,12 @@ impl<'a> Cursor<'a> {
5553 /// If requested position doesn't exist, `EOF_CHAR` is returned.
5654 /// However, getting `EOF_CHAR` doesn't always mean actual end of file,
5755 /// it should be checked with `is_eof` method.
58- #[ inline]
5956 pub fn first ( & self ) -> char {
6057 // `.next()` optimizes better than `.nth(0)`
6158 self . chars . clone ( ) . next ( ) . unwrap_or ( EOF_CHAR )
6259 }
6360
6461 /// Peeks the second symbol from the input stream without consuming it.
65- #[ inline]
6662 pub ( crate ) fn second ( & self ) -> char {
6763 // `.next()` optimizes better than `.nth(1)`
6864 let mut iter = self . chars . clone ( ) ;
@@ -71,7 +67,6 @@ impl<'a> Cursor<'a> {
7167 }
7268
7369 /// Peeks the third symbol from the input stream without consuming it.
74- #[ inline]
7570 pub fn third ( & self ) -> char {
7671 // `.next()` optimizes better than `.nth(2)`
7772 let mut iter = self . chars . clone ( ) ;
@@ -81,25 +76,21 @@ impl<'a> Cursor<'a> {
8176 }
8277
8378 /// Checks if there is nothing more to consume.
84- #[ inline]
8579 pub ( crate ) fn is_eof ( & self ) -> bool {
8680 self . chars . as_str ( ) . is_empty ( )
8781 }
8882
8983 /// Returns amount of already consumed symbols.
90- #[ inline]
9184 pub ( crate ) fn pos_within_token ( & self ) -> u32 {
9285 ( self . len_remaining - self . chars . as_str ( ) . len ( ) ) as u32
9386 }
9487
9588 /// Resets the number of bytes consumed to 0.
96- #[ inline]
9789 pub ( crate ) fn reset_pos_within_token ( & mut self ) {
9890 self . len_remaining = self . chars . as_str ( ) . len ( ) ;
9991 }
10092
10193 /// Moves to the next character.
102- #[ inline]
10394 pub ( crate ) fn bump ( & mut self ) -> Option < char > {
10495 let c = self . chars . next ( ) ?;
10596
@@ -111,10 +102,9 @@ impl<'a> Cursor<'a> {
111102 Some ( c)
112103 }
113104
114- #[ inline]
115- pub ( crate ) fn bump_if ( & mut self , expected : char ) -> bool {
105+ pub ( crate ) fn bump_if ( & mut self , byte : char ) -> bool {
116106 let mut chars = self . chars . clone ( ) ;
117- if chars. next ( ) == Some ( expected ) {
107+ if chars. next ( ) == Some ( byte ) {
118108 self . chars = chars;
119109 true
120110 } else {
@@ -123,11 +113,10 @@ impl<'a> Cursor<'a> {
123113 }
124114
125115 /// Bumps the cursor if the next character is either of the two expected characters.
126- #[ inline]
127- pub ( crate ) fn bump_if2 ( & mut self , expected1 : char , expected2 : char ) -> bool {
116+ pub ( crate ) fn bump_if_either ( & mut self , byte1 : char , byte2 : char ) -> bool {
128117 let mut chars = self . chars . clone ( ) ;
129118 if let Some ( c) = chars. next ( )
130- && ( c == expected1 || c == expected2 )
119+ && ( c == byte1 || c == byte2 )
131120 {
132121 self . chars = chars;
133122 return true ;
@@ -136,13 +125,11 @@ impl<'a> Cursor<'a> {
136125 }
137126
138127 /// Moves to a substring by a number of bytes.
139- #[ inline]
140128 pub ( crate ) fn bump_bytes ( & mut self , n : usize ) {
141- self . chars = self . as_str ( ) . get ( n..) . unwrap_or ( "" ) . chars ( ) ;
129+ self . chars = self . as_str ( ) [ n..] . chars ( ) ;
142130 }
143131
144132 /// Eats symbols while predicate returns true or until the end of file is reached.
145- #[ inline]
146133 pub ( crate ) fn eat_while ( & mut self , mut predicate : impl FnMut ( char ) -> bool ) {
147134 // It was tried making optimized version of this for eg. line comments, but
148135 // LLVM can inline all of this and compile it down to fast iteration over bytes.
@@ -152,7 +139,6 @@ impl<'a> Cursor<'a> {
152139 }
153140 /// Eats characters until the given byte is found.
154141 /// Returns true if the byte was found, false if end of file was reached.
155- #[ inline]
156142 pub ( crate ) fn eat_until ( & mut self , byte : u8 ) -> bool {
157143 match memchr:: memchr ( byte, self . as_str ( ) . as_bytes ( ) ) {
158144 Some ( index) => {
@@ -168,8 +154,7 @@ impl<'a> Cursor<'a> {
168154
169155 /// Eats characters until any of the given bytes is found, then consumes past it.
170156 /// Returns the found byte if any, or None if end of file was reached.
171- #[ inline]
172- pub ( crate ) fn eat_past2 ( & mut self , byte1 : u8 , byte2 : u8 ) -> Option < u8 > {
157+ pub ( crate ) fn eat_past_either ( & mut self , byte1 : u8 , byte2 : u8 ) -> Option < u8 > {
173158 let bytes = self . as_str ( ) . as_bytes ( ) ;
174159 match memchr:: memchr2 ( byte1, byte2, bytes) {
175160 Some ( index) => {
0 commit comments