mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	HighlightingAssets: Inline find_syntax_by_file_name() and find_syntax_by_file_name_extension()
There is no benefit to keeping separate functions.
This commit is contained in:
		@@ -258,9 +258,14 @@ impl HighlightingAssets {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn get_extension_syntax(&self, file_name: &OsStr) -> Result<Option<SyntaxReferenceInSet>> {
 | 
			
		||||
        let mut syntax = self.find_syntax_by_file_name(file_name)?;
 | 
			
		||||
        let mut syntax = self.find_syntax_by_extension(file_name.to_str().unwrap_or_default())?;
 | 
			
		||||
        if syntax.is_none() {
 | 
			
		||||
            syntax = self.find_syntax_by_file_name_extension(file_name)?;
 | 
			
		||||
            syntax = self.find_syntax_by_extension(
 | 
			
		||||
                Path::new(file_name)
 | 
			
		||||
                    .extension()
 | 
			
		||||
                    .and_then(|x| x.to_str())
 | 
			
		||||
                    .unwrap_or_default(),
 | 
			
		||||
            )?;
 | 
			
		||||
        }
 | 
			
		||||
        if syntax.is_none() {
 | 
			
		||||
            syntax = try_with_stripped_suffix(file_name, |stripped_file_name| {
 | 
			
		||||
@@ -270,22 +275,6 @@ impl HighlightingAssets {
 | 
			
		||||
        Ok(syntax)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn find_syntax_by_file_name(&self, file_name: &OsStr) -> Result<Option<SyntaxReferenceInSet>> {
 | 
			
		||||
        self.find_syntax_by_extension(file_name.to_str().unwrap_or_default())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn find_syntax_by_file_name_extension(
 | 
			
		||||
        &self,
 | 
			
		||||
        file_name: &OsStr,
 | 
			
		||||
    ) -> Result<Option<SyntaxReferenceInSet>> {
 | 
			
		||||
        self.find_syntax_by_extension(
 | 
			
		||||
            Path::new(file_name)
 | 
			
		||||
                .extension()
 | 
			
		||||
                .and_then(|x| x.to_str())
 | 
			
		||||
                .unwrap_or_default(),
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn get_first_line_syntax(
 | 
			
		||||
        &self,
 | 
			
		||||
        reader: &mut InputReader,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user