MCPcopy Create free account
hub / github.com/PerroEngine/Perro / matches

Method matches

perro_source/core/perro_csv/src/lib.rs:738–757  ·  view source on GitHub ↗
(&self, row_idx: usize)

Source from the content-addressed store, hash-verified

736 // Decorate once: fetch the cell (and parse it for numeric
737 // sorts) per row instead of per comparison.
738 let mut keyed: Vec<(usize, &str, f64)> = rows
739 .iter()
740 .map(|&row| {
741 let cell = self.table.get(row, sort.col).unwrap_or("");
742 let num = if sort.numeric {
743 cell.parse::<f64>()
744 .ok()
745 .filter(|value| value.is_finite())
746 .unwrap_or(f64::NAN)
747 } else {
748 f64::NAN
749 };
750 (row, cell, num)
751 })
752 .collect();
753 let cmp = |a: &(usize, &str, f64), b: &(usize, &str, f64)| {
754 let ord = if sort.numeric {
755 match (a.2.is_nan(), b.2.is_nan()) {
756 (false, false) => a.2.total_cmp(&b.2),
757 (false, true) => std::cmp::Ordering::Less,
758 (true, false) => std::cmp::Ordering::Greater,
759 (true, true) => a.1.cmp(b.1),
760 }

Callers 3

res_browser_sort_keyFunction · 0.80
file_path_in_scopeFunction · 0.80
runMethod · 0.80

Calls 2

predicate_matchesMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected