]> git.proxmox.com Git - proxmox-backup.git/commitdiff
AsyncIndexReader: avoid memcpy, add clippy lint fixup comment
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 14 Oct 2020 12:10:28 +0000 (14:10 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 14 Oct 2020 12:10:28 +0000 (14:10 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/backup/async_index_reader.rs

index 98372aa1988b19a807b3a60eef9f1e56086f8f84..f6a7209932039c1e6324bfaf6016c4ab005a73ae 100644 (file)
@@ -15,6 +15,17 @@ use super::IndexFile;
 use super::read_chunk::AsyncReadChunk;
 use super::index::ChunkReadInfo;
 
+// FIXME: This enum may not be required?
+// - Put the `WaitForData` case directly into a `read_future: Option<>`
+// - make the read loop as follows:
+//   * if read_buffer is not empty:
+//        use it
+//   * else if read_future is there:
+//        poll it
+//        if read: move data to read_buffer
+//   * else
+//        create read future
+#[allow(clippy::enum_variant_names)]
 enum AsyncIndexReaderState<S> {
     NoData,
     WaitForData(Pin<Box<dyn Future<Output = Result<(S, Vec<u8>), Error>> + Send + 'static>>),
@@ -118,9 +129,8 @@ where
                 }
                 AsyncIndexReaderState::WaitForData(ref mut future) => {
                     match ready!(future.as_mut().poll(cx)) {
-                        Ok((store, mut chunk_data)) => {
-                            this.read_buffer.clear();
-                            this.read_buffer.append(&mut chunk_data);
+                        Ok((store, chunk_data)) => {
+                            this.read_buffer = chunk_data;
                             this.state = AsyncIndexReaderState::HaveData;
                             this.store = Some(store);
                         }