|
13 | 13 | clippy::missing_errors_doc, |
14 | 14 | clippy::return_self_not_must_use |
15 | 15 | )] |
| 16 | + |
16 | 17 | /// Different types that can extracted from the result of `get_function_history`. |
17 | 18 | pub mod types; |
18 | 19 | use ra_ap_syntax::{ |
19 | 20 | ast::{self, HasDocComments, HasGenericParams, HasName}, |
20 | 21 | AstNode, SourceFile, SyntaxKind, |
21 | 22 | }; |
| 23 | +#[cfg(feature = "parallel")] |
22 | 24 | use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; |
23 | 25 |
|
| 26 | + |
24 | 27 | use std::{collections::HashMap, error::Error, process::Command}; |
25 | 28 | pub use types::{ |
26 | 29 | Block, BlockType, CommitFunctions, File, Function, FunctionBlock, FunctionHistory, |
@@ -188,8 +191,11 @@ pub fn get_function_history( |
188 | 191 | Err("file is not a rust file")?; |
189 | 192 | } |
190 | 193 | } |
191 | | - file_history.commit_history = commits |
192 | | - .par_iter() |
| 194 | + #[cfg(feature = "parallel")] |
| 195 | + let t = commits.par_iter(); |
| 196 | + #[cfg(not(feature = "parallel"))] |
| 197 | + let t = commits.iter(); |
| 198 | + file_history.commit_history = t |
193 | 199 | .filter_map(|commit| { |
194 | 200 | match &file { |
195 | 201 | FileType::Absolute(path) => match find_function_in_commit(commit.0, path, name) { |
@@ -566,8 +572,11 @@ fn find_function_in_commit_with_filetype( |
566 | 572 | } |
567 | 573 | } |
568 | 574 | let err = "no function found".to_string(); |
569 | | - let returns: Vec<File> = files |
570 | | - .par_iter() |
| 575 | + #[cfg(feature="parellel")] |
| 576 | + let t = files.par_iter(); |
| 577 | + #[cfg(not(feature="parellel"))] |
| 578 | + let t = files.iter(); |
| 579 | + let returns: Vec<File> = t |
571 | 580 | .filter_map(|file| match find_function_in_commit(commit, file, name) { |
572 | 581 | Ok(functions) => Some(File::new((*file).to_string(), functions)), |
573 | 582 | Err(_) => None, |
|
0 commit comments