Skip to content

Commit

Permalink
Initialise capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Oct 9, 2024
1 parent 4516239 commit a20149b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn format_file(
let old_lines = old_text.lines();
let mut old_lines = zip(1.., old_lines);
let mut queue: Vec<(usize, String)> = vec![];
let mut new_text = String::with_capacity(text.len());
let mut new_text = String::with_capacity(2 * text.len());
let indent_char = if args.usetabs { "\t" } else { " " };

loop {
Expand Down
4 changes: 2 additions & 2 deletions src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn get_diff(line: &str, pattern: &Pattern) -> i8 {
};
diff += 1;
diff += i8::try_from(
LISTS_BEGIN.iter().filter(|&r| line.contains(r)).count(),
LISTS_BEGIN.iter().any(|r| line.contains(r)),
)
.unwrap();
} else if pattern.contains_env_end && line.contains(ENV_END) {
Expand All @@ -57,7 +57,7 @@ fn get_diff(line: &str, pattern: &Pattern) -> i8 {
};
diff -= 1;
diff -= i8::try_from(
LISTS_END.iter().filter(|&r| line.contains(r)).count(),
LISTS_END.iter().any(|r| line.contains(r)),
)
.unwrap();
};
Expand Down

0 comments on commit a20149b

Please sign in to comment.