@@ -88,10 +88,9 @@ Common options:
8888
8989"# ;
9090
91- use std:: { borrow:: Cow , collections:: HashSet , fs, io :: BufWriter , path :: Path , sync:: Arc } ;
91+ use std:: { borrow:: Cow , collections:: HashSet , fs, sync:: Arc } ;
9292
9393use crossbeam_channel;
94- use csv_index:: RandomAccessSimple ;
9594#[ cfg( any( feature = "feature_capable" , feature = "lite" ) ) ]
9695use indicatif:: { HumanCount , ProgressBar , ProgressDrawTarget } ;
9796use regex:: bytes:: RegexBuilder ;
@@ -100,7 +99,7 @@ use threadpool::ThreadPool;
10099
101100use crate :: {
102101 CliError , CliResult ,
103- config:: { Config , DEFAULT_WTR_BUFFER_CAPACITY , Delimiter } ,
102+ config:: { Config , Delimiter } ,
104103 index:: Indexed ,
105104 select:: SelectColumns ,
106105 util,
@@ -178,14 +177,14 @@ fn handle_replace_results(
178177 total_match_ctr : u64 ,
179178 flag_quiet : bool ,
180179 flag_not_one : bool ,
181- ) -> CliResult < u64 > {
180+ ) -> CliResult < ( ) > {
182181 if !flag_quiet {
183182 eprintln ! ( "{total_match_ctr}" ) ;
184183 }
185184 if total_match_ctr == 0 && !flag_not_one {
186185 return Err ( CliError :: NoMatch ( ) ) ;
187186 }
188- Ok ( total_match_ctr )
187+ Ok ( ( ) )
189188}
190189
191190pub fn run ( argv : & [ & str ] ) -> CliResult < ( ) > {
@@ -226,21 +225,10 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
226225 if let Some ( idx) = rconfig. indexed ( ) ?
227226 && util:: njobs ( args. flag_jobs ) > 1
228227 {
229- let total_match_ctr = args. parallel_replace ( & idx, pattern, & rconfig, replacement) ?;
230- // refresh the index if there were any replacements
231- if total_match_ctr > 0 {
232- let mut rdr = rconfig. reader_file ( ) ?;
233- let mut wtr = BufWriter :: with_capacity (
234- DEFAULT_WTR_BUFFER_CAPACITY ,
235- fs:: File :: create ( util:: idx_path ( Path :: new ( & args. arg_input . unwrap ( ) ) ) ) ?,
236- ) ;
237- RandomAccessSimple :: create ( & mut rdr, & mut wtr) ?;
238- std:: io:: Write :: flush ( & mut wtr) ?;
239- }
228+ args. parallel_replace ( & idx, pattern, & rconfig, replacement)
240229 } else {
241- let _ = args. sequential_replace ( & pattern, & rconfig, replacement) ? ;
230+ args. sequential_replace ( & pattern, & rconfig, replacement)
242231 }
243- Ok ( ( ) )
244232}
245233
246234impl Args {
@@ -249,7 +237,7 @@ impl Args {
249237 pattern : & regex:: bytes:: Regex ,
250238 rconfig : & Config ,
251239 replacement : & [ u8 ] ,
252- ) -> CliResult < u64 > {
240+ ) -> CliResult < ( ) > {
253241 let mut rdr = rconfig. reader ( ) ?;
254242 let mut wtr = Config :: new ( self . flag_output . as_ref ( ) ) . writer ( ) ?;
255243
@@ -324,7 +312,7 @@ impl Args {
324312 pattern : regex:: bytes:: Regex ,
325313 rconfig : & Config ,
326314 replacement : & [ u8 ] ,
327- ) -> CliResult < u64 > {
315+ ) -> CliResult < ( ) > {
328316 use rayon:: slice:: ParallelSliceMut ;
329317
330318 let mut rdr = rconfig. reader ( ) ?;
@@ -333,7 +321,7 @@ impl Args {
333321
334322 let idx_count = idx. count ( ) as usize ;
335323 if idx_count == 0 {
336- return Ok ( 0 ) ;
324+ return Ok ( ( ) ) ;
337325 }
338326
339327 let njobs = util:: njobs ( self . flag_jobs ) ;
0 commit comments