File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 8
8
// which is annoying with this clippy lint
9
9
#![ allow( clippy:: default_constructed_unit_structs) ]
10
10
11
- use std:: fs:: File ;
11
+ use std:: { fs:: File , io :: BufReader } ;
12
12
13
13
use :: minijinja:: { machinery:: WhitespaceConfig , syntax:: SyntaxConfig } ;
14
14
use camino:: Utf8PathBuf ;
@@ -50,8 +50,9 @@ fn main() {
50
50
51
51
// Open the existing translation file if one was provided
52
52
let mut tree = if let Some ( path) = & options. existing {
53
- let mut file = File :: open ( path) . expect ( "Failed to open existing translation file" ) ;
54
- serde_json:: from_reader ( & mut file) . expect ( "Failed to parse existing translation file" )
53
+ let file = File :: open ( path) . expect ( "Failed to open existing translation file" ) ;
54
+ let mut reader = BufReader :: new ( file) ;
55
+ serde_json:: from_reader ( & mut reader) . expect ( "Failed to parse existing translation file" )
55
56
} else {
56
57
TranslationTree :: default ( )
57
58
} ;
Original file line number Diff line number Diff line change 4
4
// SPDX-License-Identifier: AGPL-3.0-only
5
5
// Please see LICENSE in the repository root for full details.
6
6
7
- use std:: { collections:: HashMap , fs:: File , str:: FromStr } ;
7
+ use std:: { collections:: HashMap , fs:: File , io :: BufReader , str:: FromStr } ;
8
8
9
9
use camino:: { Utf8Path , Utf8PathBuf } ;
10
10
use icu_list:: { ListError , ListFormatter , ListLength } ;
@@ -135,12 +135,14 @@ impl Translator {
135
135
Err ( source) => return Err ( LoadError :: InvalidLocale { path, source } ) ,
136
136
} ;
137
137
138
- let mut file = match File :: open ( & path) {
138
+ let file = match File :: open ( & path) {
139
139
Ok ( file) => file,
140
140
Err ( source) => return Err ( LoadError :: ReadFile { path, source } ) ,
141
141
} ;
142
142
143
- let content = match serde_json:: from_reader ( & mut file) {
143
+ let mut reader = BufReader :: new ( file) ;
144
+
145
+ let content = match serde_json:: from_reader ( & mut reader) {
144
146
Ok ( content) => content,
145
147
Err ( source) => return Err ( LoadError :: Deserialize { path, source } ) ,
146
148
} ;
You can’t perform that action at this time.
0 commit comments