This is an automated email from the ASF dual-hosted git repository.

tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 162f2bc  perf(req): avoid cloning sorted compactor items (#222)
162f2bc is described below

commit 162f2bcd5018d020aba3efbddcf5b225e5c465d1
Author: tison <[email protected]>
AuthorDate: Tue Aug 25 17:31:10 2026 +0800

    perf(req): avoid cloning sorted compactor items (#222)
---
 datasketches/src/req/compactor.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/datasketches/src/req/compactor.rs 
b/datasketches/src/req/compactor.rs
index 7d371f6..ea5c4b0 100644
--- a/datasketches/src/req/compactor.rs
+++ b/datasketches/src/req/compactor.rs
@@ -121,11 +121,14 @@ where
         debug_assert_eq!(self.lg_weight, other.lg_weight);
         self.state |= other.state;
         if !other.items.is_empty() {
-            // make sure both items are sorted.
             self.sort();
-            let mut other_items = other.items.clone();
-            other_items.sort_unstable_by(|a, b| a.total_cmp(b));
-            self.merge_sorted(&other_items);
+            if other.is_sorted {
+                self.merge_sorted(&other.items);
+            } else {
+                let mut other_items = other.items.clone();
+                other_items.sort_unstable_by(|a, b| a.total_cmp(b));
+                self.merge_sorted(&other_items);
+            }
         }
         // OR-ing the schedule counters can advance state past several doubling
         // thresholds at once. Loop until no more doublings are needed (C++:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to