Skip to content

Commit 49eb982

Browse files
committed
Replace twoway with memchr
The former is unmaintained so `cargo audit` shows a warning
1 parent 0c0b7c2 commit 49eb982

File tree

4 files changed

+16
-33
lines changed

4 files changed

+16
-33
lines changed

Cargo.lock

Lines changed: 1 addition & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

edb/edgeql-parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ base32 = "0.4.0"
1111
sha2 = "0.10.2"
1212
snafu = "0.7.0"
1313
combine = "4.5.2"
14-
twoway = "0.2.1"
14+
memchr = "2.5.0"
1515
wasm-bindgen = { version="0.2", features=["serde-serialize"], optional=true }
1616
serde = { version="1.0.106", features=["derive"], optional=true }
1717
thiserror = "1.0.23"

edb/edgeql-parser/src/preparser.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use twoway::find_bytes;
1+
use memchr::memmem::find;
22

33
#[derive(Debug, PartialEq)]
44
pub struct Continuation {
@@ -96,9 +96,8 @@ pub fn full_statement(data: &[u8], continuation: Option<Continuation>)
9696
b'$' => {
9797
match iter.next() {
9898
Some((end_idx, b'$')) => {
99-
if let Some(end) = find_bytes(&data[end_idx+1..],
100-
b"$$")
101-
{
99+
let end = find(&data[end_idx+1..], b"$$");
100+
if let Some(end) = end {
102101
iter.nth(end + end_idx - idx);
103102
continue 'outer;
104103
}
@@ -131,8 +130,8 @@ pub fn full_statement(data: &[u8], continuation: Option<Continuation>)
131130
b'$' => {
132131
let end_idx = c_idx + 1;
133132
let marker_size = end_idx - idx;
134-
if let Some(end) = find_bytes(&data[end_idx..],
135-
&data[idx..end_idx])
133+
if let Some(end) = find(&data[end_idx..],
134+
&data[idx..end_idx])
136135
{
137136
iter.nth(1 + end + marker_size - 1);
138137
continue 'outer;

edb/edgeql-parser/src/tokenizer.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::fmt;
22
use std::borrow::Cow;
33

4-
use combine::{StreamOnce, Positioned};
4+
use combine::easy::{Error, Errors};
55
use combine::error::{StreamError};
66
use combine::stream::{ResetStream};
7-
use combine::easy::{Error, Errors};
8-
use twoway::find_str;
7+
use combine::{StreamOnce, Positioned};
8+
use memchr::memmem::find;
99

1010
use crate::position::Pos;
1111

@@ -414,9 +414,9 @@ impl<'a> TokenStream<'a> {
414414
if let Some((_, c)) = iter.next() {
415415
match c {
416416
'$' => {
417-
if let Some(end) = find_str(
418-
&self.buf[self.off+2..], "$$")
419-
{
417+
let suffix = &self.buf[self.off+2..];
418+
let end = find(suffix.as_bytes(), b"$$");
419+
if let Some(end) = end {
420420
for c in self.buf[self.off+2..][..end].chars() {
421421
check_prohibited(c, false)?;
422422
}
@@ -495,9 +495,9 @@ impl<'a> TokenStream<'a> {
495495
return Err(Error::unexpected_static_message(
496496
"dollar quote supports only ascii chars"));
497497
}
498-
if let Some(end) = find_str(
499-
&self.buf[self.off+msize..],
500-
&marker)
498+
if let Some(end) = find(
499+
self.buf[self.off+msize..].as_bytes(),
500+
marker.as_bytes())
501501
{
502502
let data = &self.buf[self.off+msize..][..end];
503503
for c in data.chars() {

0 commit comments

Comments
 (0)