File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ use strum::IntoEnumIterator;
55
66pub mod language;
77
8- pub fn get_main_language ( loc_by_language_opt : Option < & Vec < ( Language , usize ) > > ) -> Option < Language > {
9- loc_by_language_opt . map ( | loc_by_language| loc_by_language [ 0 ] . 0 )
8+ pub fn get_main_language ( loc_by_language : & [ ( Language , usize ) ] ) -> Language {
9+ loc_by_language[ 0 ] . 0
1010}
1111
1212/// Returns a vector of tuples containing all the languages detected inside the repository.
@@ -35,15 +35,12 @@ fn get_loc_by_language(languages: &tokei::Languages) -> Option<HashMap<Language,
3535 for ( language_name, language) in languages {
3636 let loc = language:: loc ( language_name, language) ;
3737
38- if loc == 0 {
39- continue ;
38+ if loc > 0 {
39+ loc_by_language . insert ( Language :: from ( * language_name ) , loc ) ;
4040 }
41-
42- loc_by_language. insert ( Language :: from ( * language_name) , loc) ;
4341 }
4442
45- let total_loc: usize = loc_by_language. values ( ) . sum ( ) ;
46- if total_loc == 0 {
43+ if loc_by_language. is_empty ( ) {
4744 None
4845 } else {
4946 Some ( loc_by_language)
Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ pub fn build_info(cli_options: &CliOptions) -> Result<Info> {
159159 . join ( )
160160 . ok ( )
161161 . context ( "BUG: panic in language statistics thread" ) ?;
162- let dominant_language = langs:: get_main_language ( loc_by_language. as_ref ( ) ) ;
162+ let dominant_language = loc_by_language
163+ . as_ref ( )
164+ . map ( |v| langs:: get_main_language ( v) ) ;
163165 let ascii_colors = get_ascii_colors (
164166 dominant_language. as_ref ( ) ,
165167 cli_options. ascii . ascii_language . as_ref ( ) ,
You can’t perform that action at this time.
0 commit comments