Skip to content

Commit

Permalink
Use StdinLock instead of BufReader
Browse files Browse the repository at this point in the history
StdinLock already implements BufRead, using BufReader will only
increase the number of memcpy calls since it re-buffers.
  • Loading branch information
pickfire committed Feb 18, 2021
1 parent c22f919 commit baf1ec4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/bin/cbor2json.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let mut deserializer = serde_cbor::Deserializer::from_reader(reader);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/cbor2toml.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter, Write};
use std::io::{self, BufWriter, Write};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let mut writer = BufWriter::new(io::stdout());

let mut buffer = String::new();
Expand Down
5 changes: 3 additions & 2 deletions src/bin/cbor2yaml.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let mut deserializer = serde_cbor::Deserializer::from_reader(reader);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/json2cbor.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let writer = serde_cbor::ser::IoWrite::new(writer);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/json2toml.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter, Write};
use std::io::{self, BufWriter, Write};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let mut writer = BufWriter::new(io::stdout());

let mut buffer = String::new();
Expand Down
5 changes: 3 additions & 2 deletions src/bin/json2yaml.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let mut deserializer = serde_json::Deserializer::from_reader(reader);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/yaml2cbor.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let writer = serde_cbor::ser::IoWrite::new(writer);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/yaml2json.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufWriter};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let writer = BufWriter::new(io::stdout());

let deserializer = serde_yaml::Deserializer::from_reader(reader);
Expand Down
5 changes: 3 additions & 2 deletions src/bin/yaml2toml.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
use std::io::{self, BufReader, BufWriter, Write};
use std::io::{self, BufWriter, Write};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let reader = BufReader::new(io::stdin());
let reader = io::stdin();
let reader = reader.lock();
let mut writer = BufWriter::new(io::stdout());

let mut buffer = String::new();
Expand Down

0 comments on commit baf1ec4

Please sign in to comment.