From 6157568e1cec55ce6df09342ba0ae9686dec99c9 Mon Sep 17 00:00:00 2001 From: Mattias Wallin Date: Thu, 19 Sep 2024 18:36:00 +0200 Subject: [PATCH] Preallocate missmatches in `JsonEmitter::add_misformatted_file` The mismatches length is known to be equal to `diff.len()`. --- src/emitter/json.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emitter/json.rs b/src/emitter/json.rs index 39eae1ab0f2..8c84ff72d04 100644 --- a/src/emitter/json.rs +++ b/src/emitter/json.rs @@ -57,7 +57,7 @@ impl JsonEmitter { filename: &FileName, diff: Vec, ) -> Result<(), io::Error> { - let mut mismatches = vec![]; + let mut mismatches = Vec::with_capacity(diff.len()); for mismatch in diff { let original_begin_line = mismatch.line_number_orig; let expected_begin_line = mismatch.line_number;