Open yyzdtccjdtc opened 2 years ago
@cgag May I ask if this software is still being maintained?
Not really unfortunately, I very periodically merge stuff. I did want to comment and say this is clever though, the overhead of .iter() definitely never occurred to me.
Hi @cgag
This is a good catch. I wonder what is blocking you to merge it.
https://github.com/cgag/loc/blob/1e0c7f434ddfd51439e1d4eb126f31b7a04229d9/src/lib.rs#L668
According to my tests, the vector multis in this line of code has only one element in most cases. Calling the iter() function on a vector with only one element results in having a lot of redundant load operations. If we create a fast path for a vector with only one element, we can eliminate a lot of computation and memory operations, which in turn improves the performance of the program. Execution time decreased from 7.05s to 5.74s with my test input, which is a 22.8% speedup.
Here's the modified code for this count() function. (src/lib.rs: 597-714)
` pub fn count(filepath: &str) -> Count { let lang = lang_from_ext(filepath); let (singles, multis) = counter_config_for_lang(lang);
} `