mirror of
https://github.com/ktims/rs-aggregate.git
synced 2024-11-15 23:27:18 -08:00
Write using a BufWriter for +10% speed
This commit is contained in:
parent
675cda945f
commit
7c74cd6f7a
12
src/main.rs
12
src/main.rs
@ -1,16 +1,18 @@
|
||||
extern crate ipnet;
|
||||
extern crate iprange;
|
||||
|
||||
use std::process::exit;
|
||||
use std::{process::exit, io};
|
||||
|
||||
mod iputils;
|
||||
use iputils::{IpBothRange, IpOrNet, PrefixlenPair};
|
||||
|
||||
use clio::*;
|
||||
use std::io::BufRead;
|
||||
use std::io::{Write, BufRead};
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
const WRITER_BUFSIZE: usize = 32 * 1024;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about=None)]
|
||||
struct Args {
|
||||
@ -123,7 +125,11 @@ impl App {
|
||||
|
||||
self.simplify_inputs();
|
||||
|
||||
print!("{}", self.prefixes);
|
||||
let stdout = io::stdout().lock();
|
||||
let mut w = io::BufWriter::with_capacity(WRITER_BUFSIZE, stdout);
|
||||
|
||||
write!(&mut w, "{}", self.prefixes).unwrap();
|
||||
w.flush().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user