mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-10 18:54:22 +01:00
inline collation comparison functions
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user