Skip to content

Commit

Permalink
Use memchr to find quote characters
Browse files Browse the repository at this point in the history
  • Loading branch information
fhartwig committed Oct 13, 2016
1 parent b8a0bae commit b65cca3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ doc = false
[dependencies]
byteorder = "0.5"
rustc-serialize = "0.3"
memchr = "0.1.11"

[dev-dependencies]
regex = "0.1"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
#![deny(missing_docs)]

extern crate byteorder;
extern crate memchr;
extern crate rustc_serialize;

use std::error::Error as StdError;
Expand Down
3 changes: 2 additions & 1 deletion src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io::{self, Write};
use std::path::Path;
use std::str;

use memchr::memchr;
use rustc_serialize::Encodable;

use {
Expand Down Expand Up @@ -443,7 +444,7 @@ impl<W: io::Write> Writer<W> {

buf.push(self.quote);
loop {
match s.iter().position(|&v| v == self.quote) {
match memchr(self.quote, s) {
None => {
buf.extend_from_slice(s);
break
Expand Down

0 comments on commit b65cca3

Please sign in to comment.