Avoid string allocation in sorter record comparison

This commit is contained in:
Jussi Saurio
2025-10-09 15:34:27 +03:00
parent e0461dd78a
commit bcca404551

View File

@@ -686,8 +686,9 @@ impl Ord for SortableImmutableRecord {
let cmp = match (this_key_value, other_key_value) {
(ValueRef::Text(left, _), ValueRef::Text(right, _)) => collation.compare_strings(
&String::from_utf8_lossy(left),
&String::from_utf8_lossy(right),
// SAFETY: these were checked to be valid UTF-8 on construction.
unsafe { std::str::from_utf8_unchecked(left) },
unsafe { std::str::from_utf8_unchecked(right) },
),
_ => this_key_value.partial_cmp(&other_key_value).unwrap(),
};