summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2017-05-24 23:02:05 -0400
committerAndrew Gallant <jamslam@gmail.com>2017-05-24 23:16:31 -0400
commitb0da83b82511efefbc4458ccd40109f98e3189fb (patch)
tree2c8fd114e1e42619a60f226240b0614a38b969f1
parent0f58a988016327016378a21bf4e335a41b51b2e9 (diff)
small performance improvements0.12.1
For the most part, this switches write_record to write_byte_record where possible, and also moves some uses of the `byte_records` iterator to the manual `read_byte_record` method, which permits us to amortize allocation. This also removes the use of normal selection for `xsv search`, which was causing a huge slow down. Also, bump to csv 1.0.0.beta.3.
-rw-r--r--BENCHMARKS.md36
-rw-r--r--Cargo.lock48
-rw-r--r--Cargo.toml5
-rw-r--r--src/cmd/cat.rs7
-rw-r--r--src/cmd/fixlengths.rs2
-rw-r--r--src/cmd/fmt.rs5
-rw-r--r--src/cmd/input.rs7
-rw-r--r--src/cmd/partition.rs7
-rw-r--r--src/cmd/sample.rs2
-rw-r--r--src/cmd/search.rs11
-rw-r--r--src/cmd/slice.rs4
-rw-r--r--src/cmd/sort.rs2
-rw-r--r--src/cmd/split.rs9
-rw-r--r--src/config.rs10
-rw-r--r--src/main.rs9
15 files changed, 86 insertions, 78 deletions
diff --git a/BENCHMARKS.md b/BENCHMARKS.md
index 7326a49..e8bfbad 100644
--- a/BENCHMARKS.md
+++ b/BENCHMARKS.md
@@ -10,23 +10,25 @@ These benchmarks were run on an Intel i7-6900K (8 CPUs, 16 threads) with 64GB
of memory.
```
-count 0.11 seconds 413.76 MB/sec
-flatten 4.54 seconds 10.02 MB/sec
-flatten_condensed 4.45 seconds 10.22 MB/sec
-frequency 1.82 seconds 25.00 MB/sec
-index 0.12 seconds 379.28 MB/sec
-sample_10 0.18 seconds 252.85 MB/sec
-sample_1000 0.18 seconds 252.85 MB/sec
-sample_100000 0.29 seconds 156.94 MB/sec
-search 0.27 seconds 168.56 MB/sec
-select 0.14 seconds 325.09 MB/sec
-sort 2.18 seconds 20.87 MB/sec
-slice_one_middle 0.08 seconds 568.92 MB/sec
-slice_one_middle_index 0.01 seconds 4551.36 MB/sec
-stats 1.09 seconds 41.75 MB/sec
-stats_index 0.15 seconds 303.42 MB/sec
-stats_everything 1.94 seconds 23.46 MB/sec
-stats_everything_index 0.93 seconds 48.93 MB/sec
+count 0.11 seconds 413.76 MB/sec
+flatten 4.54 seconds 10.02 MB/sec
+flatten_condensed 4.45 seconds 10.22 MB/sec
+frequency 1.82 seconds 25.00 MB/sec
+index 0.12 seconds 379.28 MB/sec
+sample_10 0.18 seconds 252.85 MB/sec
+sample_1000 0.18 seconds 252.85 MB/sec
+sample_100000 0.29 seconds 156.94 MB/sec
+search 0.27 seconds 168.56 MB/sec
+select 0.14 seconds 325.09 MB/sec
+search 0.13 seconds 350.10 MB/sec
+select 0.13 seconds 350.10 MB/sec
+sort 2.18 seconds 20.87 MB/sec
+slice_one_middle 0.08 seconds 568.92 MB/sec
+slice_one_middle_index 0.01 seconds 4551.36 MB/sec
+stats 1.09 seconds 41.75 MB/sec
+stats_index 0.15 seconds 303.42 MB/sec
+stats_everything 1.94 seconds 23.46 MB/sec
+stats_everything_index 0.93 seconds 48.93 MB/sec
```
### Details
diff --git a/Cargo.lock b/Cargo.lock
index 78154df..4bc2439 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,18 +4,18 @@ version = "0.12.0"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chan 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "csv 1.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "csv-index 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv 1.0.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv-index 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quickcheck 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"streaming-stats 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"tabwriter 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -44,16 +44,16 @@ dependencies = [
[[package]]
name = "csv"
-version = "1.0.0-beta.1"
+version = "1.0.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "csv-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "csv-core"
-version = "0.1.0"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -61,12 +61,12 @@ dependencies = [
[[package]]
name = "csv-index"
-version = "0.1.0"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "csv 1.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "csv-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv 1.0.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "csv-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -109,7 +109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
-version = "0.3.7"
+version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -239,22 +239,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
-version = "1.0.7"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
-version = "1.0.7"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive_internals"
-version = "0.15.0"
+version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -365,15 +365,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
"checksum chan 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "f93bfe971116428a9066c1c3c69a09ae3ef69432f8418be28ab50f96783e6a50"
-"checksum csv 1.0.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81675dd89651e2aa0989e6a5249dc5c5bcfc13772baec7f9652208e7691e0955"
-"checksum csv-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a11ab3094dd197341f9d66753789a5cdf29ce35450a7d6e7968024e2d44519c"
-"checksum csv-index 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7405ccdb151a01a4844b2cf851e2806dca2bdec892537057bf0719f4a7504c60"
+"checksum csv 1.0.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "158edc15f3da84af2ae2689ab84157f7f94a21dff3dec455320cf44be8963433"
+"checksum csv-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ed4919aaefb12f555bb4e34aa6415b5db7e20e01e517427f13c2bde286ae9b53"
+"checksum csv-index 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22fe847d4629c76b667e11da543f7e0da336e9aa39487ecd3e3a1f9517a06c47"
"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8"
"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
"checksum libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e7eb6b826bfc1fdea7935d46556250d1799b7fe2d9f7951071f4291710665e3e"
-"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad"
+"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
"checksum num 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "98b15ba84e910ea7a1973bccd3df7b31ae282bf9d8bd2897779950c9b8303d40"
"checksum num-bigint 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "ba6d838b16e56da1b6c383d065ff1ec3c7d7797f65a3e8f6ba7092fd87820bac"
@@ -389,9 +389,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
-"checksum serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c0c3d79316a6051231925504f6ef893d45088e8823c77a8331a3dcf427ee9087"
-"checksum serde_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0019cd5b9f0529a1a0e145a912e9a2d60c325c58f7f260fc36c71976e9d76aee"
-"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1"
+"checksum serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f530d36fb84ec48fb7146936881f026cdbf4892028835fd9398475f82c1bb4"
+"checksum serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "10552fad5500771f3902d0c5ba187c5881942b811b7ba0d8fbbfbf84d80806d3"
+"checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a"
"checksum streaming-stats 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "f13d0cd680e11a62c5e125d9799debfb39fcfff9a2ef416336ce748f65018b89"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
diff --git a/Cargo.toml b/Cargo.toml
index b9e386d..c4fe495 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,7 @@ name = "tests"
[profile.release]
opt-level = 3
+debug = true
[profile.test]
opt-level = 3
@@ -28,8 +29,8 @@ opt-level = 3
[dependencies]
byteorder = "1"
chan = "0.1"
-csv = "1.0.0-beta.1"
-csv-index = "0.1"
+csv = "1.0.0-beta.3"
+csv-index = "0.1.2"
docopt = "0.7"
filetime = "0.1"
num_cpus = "1.4"
diff --git a/src/cmd/cat.rs b/src/cmd/cat.rs
index 7e7c1f3..9c838bf 100644
--- a/src/cmd/cat.rs
+++ b/src/cmd/cat.rs
@@ -69,14 +69,15 @@ impl Args {
}
fn cat_rows(&self) -> CliResult<()> {
+ let mut row = csv::ByteRecord::new();
let mut wtr = Config::new(&self.flag_output).writer()?;
for (i, conf) in self.configs()?.into_iter().enumerate() {
let mut rdr = conf.reader()?;
if i == 0 {
conf.write_headers(&mut rdr, &mut wtr)?;
}
- for r in rdr.byte_records() {
- wtr.write_record(&r?)?;
+ while rdr.read_byte_record(&mut row)? {
+ wtr.write_byte_record(&row)?;
}
}
wtr.flush().map_err(From::from)
@@ -124,7 +125,7 @@ impl Args {
if num_done >= iters.len() {
break 'OUTER;
}
- wtr.write_record(&record)?;
+ wtr.write_byte_record(&record)?;
}
wtr.flush().map_err(From::from)
}
diff --git a/src/cmd/fixlengths.rs b/src/cmd/fixlengths.rs
index eb176bb..feaed67 100644
--- a/src/cmd/fixlengths.rs
+++ b/src/cmd/fixlengths.rs
@@ -88,7 +88,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
} else {
r.truncate(length);
}
- wtr.write_record(&r)?;
+ wtr.write_byte_record(&r)?;
}
wtr.flush()?;
Ok(())
diff --git a/src/cmd/fmt.rs b/src/cmd/fmt.rs
index 4bd7070..3878408 100644
--- a/src/cmd/fmt.rs
+++ b/src/cmd/fmt.rs
@@ -72,8 +72,9 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut rdr = rconfig.reader()?;
let mut wtr = wconfig.writer()?;
- for r in rdr.byte_records() {
- wtr.write_record(&r?)?;
+ let mut r = csv::ByteRecord::new();
+ while rdr.read_byte_record(&mut r)? {
+ wtr.write_byte_record(&r)?;
}
wtr.flush()?;
Ok(())
diff --git a/src/cmd/input.rs b/src/cmd/input.rs
index f16a712..17d9c44 100644
--- a/src/cmd/input.rs
+++ b/src/cmd/input.rs
@@ -1,3 +1,5 @@
+use csv;
+
use CliResult;
use config::{Config, Delimiter};
use util;
@@ -48,8 +50,9 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut rdr = rconfig.reader()?;
let mut wtr = wconfig.writer()?;
- for r in rdr.byte_records() {
- wtr.write_record(&r?)?;
+ let mut row = csv::ByteRecord::new();
+ while rdr.read_byte_record(&mut row)? {
+ wtr.write_record(&row)?;
}
wtr.flush()?;
Ok(())
diff --git a/src/cmd/partition.rs b/src/cmd/partition.rs
index 687302c..224f3dd 100644
--- a/src/cmd/partition.rs
+++ b/src/cmd/partition.rs
@@ -96,9 +96,8 @@ impl Args {
let mut writers: HashMap<Vec<u8>, BoxedWriter> =
HashMap::new();
- for row in rdr.byte_records() {
- let row = row?;
-
+ let mut row = csv::ByteRecord::new();
+ while rdr.read_byte_record(&mut row)? {
// Decide what file to put this in.
let column = &row[key_col];
let key = match self.flag_prefix_length {
@@ -118,7 +117,7 @@ impl Args {
vacant.insert(wtr)
}
};
- wtr.write_record(&row)?;
+ wtr.write_byte_record(&row)?;
}
Ok(())
}
diff --git a/src/cmd/sample.rs b/src/cmd/sample.rs
index 20bef81..3e919d7 100644
--- a/src/cmd/sample.rs
+++ b/src/cmd/sample.rs
@@ -73,7 +73,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
};
for row in sampled.into_iter() {
- wtr.write_record(&row)?;
+ wtr.write_byte_record(&row)?;
}
Ok(wtr.flush()?)
}
diff --git a/src/cmd/search.rs b/src/cmd/search.rs
index 7ebc506..78996dc 100644
--- a/src/cmd/search.rs
+++ b/src/cmd/search.rs
@@ -1,3 +1,4 @@
+use csv;
use regex::bytes::RegexBuilder;
use CliResult;
@@ -60,19 +61,19 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut wtr = Config::new(&args.flag_output).writer()?;
let headers = rdr.byte_headers()?.clone();
- let nsel = rconfig.normal_selection(&headers)?;
+ let sel = rconfig.selection(&headers)?;
if !rconfig.no_headers {
wtr.write_record(&headers)?;
}
- for row in rdr.byte_records() {
- let row = row?;
- let mut m = nsel.select(row.iter()).any(|f| pattern.is_match(f));
+ let mut record = csv::ByteRecord::new();
+ while rdr.read_byte_record(&mut record)? {
+ let mut m = sel.select(&record).any(|f| pattern.is_match(f));
if args.flag_invert_match {
m = !m;
}
if m {
- wtr.write_record(&row)?;
+ wtr.write_byte_record(&record)?;
}
}
Ok(wtr.flush()?)
diff --git a/src/cmd/slice.rs b/src/cmd/slice.rs
index 5a6e7e0..334b01b 100644
--- a/src/cmd/slice.rs
+++ b/src/cmd/slice.rs
@@ -69,7 +69,7 @@ impl Args {
let (start, end) = self.range()?;
for r in rdr.byte_records().skip(start).take(end - start) {
- wtr.write_record(&r?)?;
+ wtr.write_byte_record(&r?)?;
}
Ok(wtr.flush()?)
}
@@ -87,7 +87,7 @@ impl Args {
}
idx.seek(start as u64)?;
for r in idx.byte_records().take(end - start) {
- wtr.write_record(&r?)?;
+ wtr.write_byte_record(&r?)?;
}
wtr.flush()?;
Ok(())
diff --git a/src/cmd/sort.rs b/src/cmd/sort.rs
index 0db828c..647fb3c 100644
--- a/src/cmd/sort.rs
+++ b/src/cmd/sort.rs
@@ -87,7 +87,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
rconfig.write_headers(&mut rdr, &mut wtr)?;
for r in all.into_iter() {
- wtr.write_record(&r)?;
+ wtr.write_byte_record(&r)?;
}
Ok(wtr.flush()?)
}
diff --git a/src/cmd/split.rs b/src/cmd/split.rs
index 01b90a5..b6b8c31 100644
--- a/src/cmd/split.rs
+++ b/src/cmd/split.rs
@@ -77,12 +77,15 @@ impl Args {
let headers = rdr.byte_headers()?.clone();
let mut wtr = self.new_writer(&headers, 0)?;
- for (i, row) in rdr.byte_records().enumerate() {
+ let mut i = 0;
+ let mut row = csv::ByteRecord::new();
+ while rdr.read_byte_record(&mut row)? {
if i > 0 && i % self.flag_size == 0 {
wtr.flush()?;
wtr = self.new_writer(&headers, i)?;
}
- wtr.write_record(&row?)?;
+ wtr.write_byte_record(&row)?;
+ i += 1;
}
wtr.flush()?;
Ok(())
@@ -111,7 +114,7 @@ impl Args {
idx.seek((i * args.flag_size) as u64).unwrap();
for row in idx.byte_records().take(args.flag_size) {
let row = row.unwrap();
- wtr.write_record(row.into_iter()).unwrap();
+ wtr.write_byte_record(&row).unwrap();
}
wtr.flush().unwrap();
wg.done();
diff --git a/src/config.rs b/src/config.rs
index 41cd9a7..063d2dc 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -11,7 +11,7 @@ use index::Indexed;
use rustc_serialize::{Decodable, Decoder};
use CliResult;
-use select::{SelectColumns, Selection, NormalSelection};
+use select::{SelectColumns, Selection};
use util;
@@ -172,13 +172,6 @@ impl Config {
}
}
- pub fn normal_selection(
- &self,
- first_record: &csv::ByteRecord,
- ) -> Result<NormalSelection, String> {
- self.selection(first_record).map(|sel| sel.normal())
- }
-
pub fn write_headers<R: io::Read, W: io::Write>
(&self, r: &mut csv::Reader<R>, w: &mut csv::Writer<W>)
-> csv::Result<()> {
@@ -301,6 +294,7 @@ impl Config {
.quote_style(self.quote_style)
.double_quote(self.double_quote)
.escape(self.escape)
+ .buffer_capacity(32 * (1<<10))
.from_writer(wtr)
}
}
diff --git a/src/main.rs b/src/main.rs
index ca0f5ce..f0d4d81 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -216,9 +216,12 @@ impl From<docopt::Error> for CliError {
impl From<csv::Error> for CliError {
fn from(err: csv::Error) -> CliError {
- match err {
- csv::Error::Io(v) => From::from(v),
- v => CliError::Csv(v),
+ if !err.is_io_error() {
+ return CliError::Csv(err);
+ }
+ match err.into_kind() {
+ csv::ErrorKind::Io(v) => From::from(v),
+ _ => unreachable!(),
}
}
}