syntactic changes: remove unneeded mut, lifetimes,references that get instantaneously dereferenced and casts

This commit is contained in:
Jorge López
2025-01-18 18:43:47 +01:00
parent 2cc8cb9ad8
commit 218a2e6dda
8 changed files with 15 additions and 15 deletions

View File

@@ -190,7 +190,7 @@ pub fn json_extract(value: &OwnedValue, paths: &[OwnedValue]) -> crate::Result<O
let json = get_json_value(value)?;
let extracted = json_extract_single(&json, &paths[0], true)?.unwrap_or_else(|| &Val::Null);
return convert_json_to_db_type(&extracted, false);
return convert_json_to_db_type(extracted, false);
}
let json = get_json_value(value)?;
@@ -369,7 +369,7 @@ fn json_extract_single<'a>(
}
}
Ok(Some(&current_element))
Ok(Some(current_element))
}
pub fn json_error_position(json: &OwnedValue) -> crate::Result<OwnedValue> {

View File

@@ -76,7 +76,7 @@ impl Parameters {
log::trace!("anonymous parameter at {index}");
index
}
name if name.starts_with(&['$', ':', '@', '#']) => {
name if name.starts_with(['$', ':', '@', '#']) => {
match self
.list
.iter()

View File

@@ -167,7 +167,7 @@ impl BTreeCursor {
/// Check if the table is empty.
/// This is done by checking if the root page has no cells.
fn is_empty_table(&mut self) -> Result<CursorResult<bool>> {
fn is_empty_table(&self) -> Result<CursorResult<bool>> {
let page = self.pager.read_page(self.root_page)?;
return_if_locked!(page);
@@ -473,7 +473,7 @@ impl BTreeCursor {
&record.values[..record.values.len() - 1] >= &index_key.values
}
SeekOp::EQ => {
&record.values[..record.values.len() - 1] == &index_key.values
record.values[..record.values.len() - 1] == index_key.values
}
};
self.stack.advance();

View File

@@ -290,9 +290,9 @@ fn emit_program_for_delete(
Ok(())
}
fn emit_delete_insns<'a>(
fn emit_delete_insns(
program: &mut ProgramBuilder,
t_ctx: &mut TranslateCtx<'a>,
t_ctx: &mut TranslateCtx,
source: &SourceOperator,
limit: &Option<usize>,
) -> Result<()> {

View File

@@ -12,7 +12,7 @@ use crate::{
};
use sqlite3_parser::ast::{self, Expr, FromClause, JoinType, Limit};
pub const ROWID: &'static str = "rowid";
pub const ROWID: &str = "rowid";
pub struct OperatorIdCounter {
id: usize,

View File

@@ -12,9 +12,9 @@ use super::{
/// Emit the subqueries contained in the FROM clause.
/// This is done first so the results can be read in the main query loop.
pub fn emit_subqueries<'a>(
pub fn emit_subqueries(
program: &mut ProgramBuilder,
t_ctx: &mut TranslateCtx<'a>,
t_ctx: &mut TranslateCtx,
referenced_tables: &mut [TableReference],
source: &mut SourceOperator,
) -> Result<()> {

View File

@@ -579,14 +579,14 @@ fn parse_modifier(modifier: &str) -> Result<Modifier> {
if parts[0].len() == digits_in_date {
let date = parse_modifier_date(parts[0])?;
Ok(Modifier::DateOffset {
years: sign * date.year() as i32,
years: sign * date.year(),
months: sign * date.month() as i32,
days: sign * date.day() as i32,
})
} else {
// time values are either 12, 8 or 5 digits
let time = parse_modifier_time(parts[0])?;
let time_delta = (sign * (time.num_seconds_from_midnight() as i32)) as i32;
let time_delta = sign * (time.num_seconds_from_midnight() as i32);
Ok(Modifier::TimeOffset(TimeDelta::seconds(time_delta.into())))
}
}
@@ -596,7 +596,7 @@ fn parse_modifier(modifier: &str) -> Result<Modifier> {
// Convert time to total seconds (with sign)
let time_delta = sign * (time.num_seconds_from_midnight() as i32);
Ok(Modifier::DateTimeOffset {
years: sign * (date.year() as i32),
years: sign * (date.year()),
months: sign * (date.month() as i32),
days: sign * date.day() as i32,
seconds: time_delta,

View File

@@ -2311,7 +2311,7 @@ fn trace_insn(program: &Program, addr: InsnReference, insn: &Insn) {
addr,
insn,
String::new(),
program.comments.get(&(addr as u32)).copied()
program.comments.get(&{ addr }).copied()
)
);
}
@@ -2322,7 +2322,7 @@ fn print_insn(program: &Program, addr: InsnReference, insn: &Insn, indent: Strin
addr,
insn,
indent,
program.comments.get(&(addr as u32)).copied(),
program.comments.get(&{ addr }).copied(),
);
println!("{}", s);
}