Applies some recent Clippy lints

pull/564/head
Thomas 1 year ago committed by Thomas Tanon
parent c8e718ed2d
commit 24a1dd2556
  1. 2
      lib/spargebra/src/query.rs
  2. 2
      lib/src/sparql/plan.rs
  3. 32
      testsuite/benches/parser.rs
  4. 2
      testsuite/src/sparql_evaluator.rs

@ -210,7 +210,7 @@ impl fmt::Display for Query {
writeln!(f, "BASE <{base_iri}>")?;
}
write!(f, "CONSTRUCT {{ ")?;
for triple in template.iter() {
for triple in template {
write!(f, "{triple} . ")?;
}
write!(f, "}}")?;

@ -155,7 +155,7 @@ impl PlanNode {
child.lookup_used_variables(callback);
}
Self::Union { children } => {
for child in children.iter() {
for child in children {
child.lookup_used_variables(callback);
}
}

@ -1,3 +1,5 @@
#![allow(clippy::print_stderr)]
use anyhow::Result;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use oxigraph_testsuite::files::read_file;
@ -40,7 +42,7 @@ fn parse_bench(
c: &mut Criterion,
parser_name: &str,
data_name: &str,
data: Vec<u8>,
data: &[u8],
bench: impl Fn(&[u8]),
) {
let mut group = c.benchmark_group(parser_name);
@ -51,7 +53,7 @@ fn parse_bench(
group.finish();
}
fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) {
fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: &[u8]) {
parse_bench(c, "oxttl ntriples", name, data, |data| {
let mut parser = oxttl::NTriplesParser::new().parse();
parser.extend_from_slice(data);
@ -62,7 +64,7 @@ fn parse_oxttl_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) {
});
}
fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) {
fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: &[u8]) {
parse_bench(c, "oxttl turtle", name, data, |data| {
let mut parser = oxttl::TurtleParser::new().parse();
parser.extend_from_slice(data);
@ -73,25 +75,25 @@ fn parse_oxttl_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) {
});
}
fn parse_rio_ntriples(c: &mut Criterion, name: &str, data: Vec<u8>) {
fn parse_rio_ntriples(c: &mut Criterion, name: &str, data: &[u8]) {
parse_bench(c, "rio ntriples", name, data, |data| {
let mut count: u64 = 0;
NTriplesParser::new(data)
.parse_all(&mut |_| {
.parse_all::<TurtleError>(&mut |_| {
count += 1;
Ok(()) as Result<(), TurtleError>
Ok(())
})
.unwrap();
});
}
fn parse_rio_turtle(c: &mut Criterion, name: &str, data: Vec<u8>) {
fn parse_rio_turtle(c: &mut Criterion, name: &str, data: &[u8]) {
parse_bench(c, "rio turtle", name, data, |data| {
let mut count: u64 = 0;
TurtleParser::new(data, None)
.parse_all(&mut |_| {
.parse_all::<TurtleError>(&mut |_| {
count += 1;
Ok(()) as Result<(), TurtleError>
Ok(())
})
.unwrap();
});
@ -101,7 +103,7 @@ fn bench_parse_oxttl_ntriples_with_ntriples(c: &mut Criterion) {
parse_oxttl_ntriples(
c,
"ntriples",
match ntriples_test_data() {
&match ntriples_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");
@ -115,7 +117,7 @@ fn bench_parse_oxttl_ntriples_with_turtle(c: &mut Criterion) {
parse_oxttl_turtle(
c,
"ntriples",
match ntriples_test_data() {
&match ntriples_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");
@ -129,7 +131,7 @@ fn bench_parse_oxttl_turtle_with_turtle(c: &mut Criterion) {
parse_oxttl_turtle(
c,
"turtle",
match turtle_test_data() {
&match turtle_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");
@ -143,7 +145,7 @@ fn bench_parse_rio_ntriples_with_ntriples(c: &mut Criterion) {
parse_rio_ntriples(
c,
"ntriples",
match ntriples_test_data() {
&match ntriples_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");
@ -157,7 +159,7 @@ fn bench_parse_rio_ntriples_with_turtle(c: &mut Criterion) {
parse_rio_turtle(
c,
"ntriples",
match ntriples_test_data() {
&match ntriples_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");
@ -171,7 +173,7 @@ fn bench_parse_rio_turtle_with_turtle(c: &mut Criterion) {
parse_rio_turtle(
c,
"turtle",
match turtle_test_data() {
&match turtle_test_data() {
Ok(d) => d,
Err(e) => {
eprintln!("{e}");

@ -501,7 +501,7 @@ impl StaticQueryResults {
fn from_graph(graph: &Graph) -> Result<Self> {
// Hack to normalize literals
let store = Store::new()?;
for t in graph.iter() {
for t in graph {
store
.insert(t.in_graph(GraphNameRef::DefaultGraph))
.unwrap();

Loading…
Cancel
Save