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}>")?; writeln!(f, "BASE <{base_iri}>")?;
} }
write!(f, "CONSTRUCT {{ ")?; write!(f, "CONSTRUCT {{ ")?;
for triple in template.iter() { for triple in template {
write!(f, "{triple} . ")?; write!(f, "{triple} . ")?;
} }
write!(f, "}}")?; write!(f, "}}")?;

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

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

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

Loading…
Cancel
Save