Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-536

Eliminate redundant clones

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0-beta.2
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently, CommandResponse::body takes in self by reference, requiring a clone of the underlying response document for deserialization. In many cases this clone is unnecessary however, since the CommandResponse is discarded after the call to body anyways. As a performance improvement, body could instead take ownership of self and avoid the clone. In cases where the response would need to be used again, it could be cloned before calling body. Alternatively, we could introduce two variants of body depending on if cloning is desired.

      execute_operation also makes some redundant clones of the already constructed Command, further degrading performance.

      Insert::build requires cloning of the to-be-inserted documents, but references to the documents could be stored instead to prevent the unnecessary clone.

      We should eliminate all these redundant clones to improve the performance of the driver.

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: