inline collation comparison functions

This commit is contained in:
Jussi Saurio
2025-10-09 18:23:47 +03:00
parent 0356a7102c
commit 812709cf8e

View File

@@ -1,6 +1,5 @@
use std::{cmp::Ordering, str::FromStr as _};
use tracing::Level;
use turso_parser::ast::Expr;
use crate::{
@@ -37,8 +36,8 @@ impl CollationSeq {
})
}
#[inline(always)]
pub fn compare_strings(&self, lhs: &str, rhs: &str) -> Ordering {
tracing::event!(Level::DEBUG, collate = %self, lhs, rhs);
match self {
CollationSeq::Binary => Self::binary_cmp(lhs, rhs),
CollationSeq::NoCase => Self::nocase_cmp(lhs, rhs),
@@ -46,16 +45,19 @@ impl CollationSeq {
}
}
#[inline(always)]
fn binary_cmp(lhs: &str, rhs: &str) -> Ordering {
lhs.cmp(rhs)
}
#[inline(always)]
fn nocase_cmp(lhs: &str, rhs: &str) -> Ordering {
let nocase_lhs = uncased::UncasedStr::new(lhs);
let nocase_rhs = uncased::UncasedStr::new(rhs);
nocase_lhs.cmp(nocase_rhs)
}
#[inline(always)]
fn rtrim_cmp(lhs: &str, rhs: &str) -> Ordering {
lhs.trim_end().cmp(rhs.trim_end())
}