From: Robert Obkircher <r.obkircher@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH v1 proxmox-backup 03/11] datastore+server: sort by key instead of using comparison functions
Date: Thu, 26 Feb 2026 15:40:17 +0100 [thread overview]
Message-ID: <20260226144033.211039-4-r.obkircher@proxmox.com> (raw)
In-Reply-To: <20260226144033.211039-1-r.obkircher@proxmox.com>
Make sorting more readable and fix mulitple clippy warnings.
Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
---
pbs-datastore/src/backup_info.rs | 4 ++--
pbs-datastore/src/datastore.rs | 4 +---
src/server/pull.rs | 2 +-
src/server/push.rs | 2 +-
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs
index 859039cf..9e298ee8 100644
--- a/pbs-datastore/src/backup_info.rs
+++ b/pbs-datastore/src/backup_info.rs
@@ -851,10 +851,10 @@ impl BackupInfo {
pub fn sort_list(list: &mut [BackupInfo], ascendending: bool) {
if ascendending {
// oldest first
- list.sort_unstable_by(|a, b| a.backup_dir.dir.time.cmp(&b.backup_dir.dir.time));
+ list.sort_unstable_by_key(|a| a.backup_dir.dir.time);
} else {
// newest first
- list.sort_unstable_by(|a, b| b.backup_dir.dir.time.cmp(&a.backup_dir.dir.time));
+ list.sort_unstable_by_key(|b| std::cmp::Reverse(b.backup_dir.dir.time));
}
}
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 7ad3d917..51e38ea4 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -2250,9 +2250,7 @@ impl DataStore {
match self.inner.chunk_order {
// sorting by inode improves data locality, which makes it lots faster on spinners
- ChunkOrder::Inode => {
- chunk_list.sort_unstable_by(|(_, ino_a), (_, ino_b)| ino_a.cmp(ino_b))
- }
+ ChunkOrder::Inode => chunk_list.sort_unstable_by_key(|(_, ino)| *ino),
ChunkOrder::None => {}
}
diff --git a/src/server/pull.rs b/src/server/pull.rs
index 15d8b9de..57c5ef32 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -622,7 +622,7 @@ async fn pull_group(
.source
.list_backup_snapshots(source_namespace, group)
.await?;
- raw_list.sort_unstable_by(|a, b| a.backup.time.cmp(&b.backup.time));
+ raw_list.sort_unstable_by_key(|a| a.backup.time);
let target_ns = source_namespace.map_prefix(¶ms.source.get_ns(), ¶ms.target.ns)?;
diff --git a/src/server/push.rs b/src/server/push.rs
index d7884fce..b1c509b0 100644
--- a/src/server/push.rs
+++ b/src/server/push.rs
@@ -679,7 +679,7 @@ pub(crate) async fn push_group(
.source
.list_backup_snapshots(namespace, group)
.await?;
- snapshots.sort_unstable_by(|a, b| a.backup.time.cmp(&b.backup.time));
+ snapshots.sort_unstable_by_key(|a| a.backup.time);
if snapshots.is_empty() {
info!("Group '{group}' contains no snapshots to sync to remote");
--
2.47.3
next prev parent reply other threads:[~2026-02-26 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 14:40 [PATCH v1 proxmox-backup 00/11] fix various warnings Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 01/11] datastore: remove allow(clippy::cast_ptr_alignment) attribute Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 02/11] api: use checked_div for compression ratio calculation Robert Obkircher
2026-02-26 14:40 ` Robert Obkircher [this message]
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 04/11] api: remove unnecessary ampersand to fix clippy warning Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 05/11] bin: debug: use pattern match instead of is_some+unwrap Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 06/11] bin: proxy: fix clippy warning about unnecesary use of find_map Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 07/11] datastore: silence warning about too many arguments Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 08/11] client: catalog shell: avoid unnecessary block_on in async code Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 09/11] client: catalog shell: combine multiple block_on calls into one Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 10/11] client: catalog shell: avoid unsafe transmute Robert Obkircher
2026-02-26 14:40 ` [PATCH v1 proxmox-backup 11/11] tape: media catalog: use Flock wrapper instead of deprecated function Robert Obkircher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226144033.211039-4-r.obkircher@proxmox.com \
--to=r.obkircher@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox