Remove owned String from CustomError.
This is a 15% performance improvement.
This commit is contained in:
		
							parent
							
								
									acfc5e5e68
								
							
						
					
					
						commit
						f47d688be4
					
				| @ -6,8 +6,6 @@ pub(crate) type Res<T, U> = IResult<T, U, CustomError>; | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub enum CustomError { | ||||
|     #[allow(dead_code)] | ||||
|     Text(String), | ||||
|     Static(&'static str), | ||||
|     IO(std::io::Error), | ||||
|     Parser(ErrorKind), | ||||
| @ -35,9 +33,3 @@ impl From<&'static str> for CustomError { | ||||
|         CustomError::Static(value) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<String> for CustomError { | ||||
|     fn from(value: String) -> Self { | ||||
|         CustomError::Text(value) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -102,7 +102,7 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>( | ||||
|     }) { | ||||
|         let (_, (in_progress_words, complete_words)) = | ||||
|             todo_keywords(kw.value).map_err(|err| match err { | ||||
|                 nom::Err::Incomplete(_) => CustomError::Text(err.to_string()), | ||||
|                 nom::Err::Incomplete(_) => panic!("This parser does not support streaming."), | ||||
|                 nom::Err::Error(e) => e, | ||||
|                 nom::Err::Failure(e) => e, | ||||
|             })?; | ||||
| @ -123,7 +123,7 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>( | ||||
|             kw.value, | ||||
|         ) | ||||
|         .map_err(|err: nom::Err<_>| match err { | ||||
|             nom::Err::Incomplete(_) => CustomError::Text(err.to_string()), | ||||
|             nom::Err::Incomplete(_) => panic!("This parser does not support streaming."), | ||||
|             nom::Err::Error(e) => e, | ||||
|             nom::Err::Failure(e) => e, | ||||
|         })?; | ||||
| @ -141,7 +141,7 @@ pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>( | ||||
|         .filter(|kw| kw.key.eq_ignore_ascii_case("link")) | ||||
|     { | ||||
|         let (_, (link_key, link_value)) = link_template(kw.value).map_err(|err| match err { | ||||
|             nom::Err::Incomplete(_) => CustomError::Text(err.to_string()), | ||||
|             nom::Err::Incomplete(_) => panic!("This parser does not support streaming."), | ||||
|             nom::Err::Error(e) => e, | ||||
|             nom::Err::Failure(e) => e, | ||||
|         })?; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander