Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid cloning values during reduce #347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Nov 19, 2021

  1. reduce_core: present referenced data to logic function

    `reduce_core` was previously forced to clone the output data before
    presenting it to the logic function for inspection.
    
    Simply annotating the type with a reference was not possible due to the
    buffer being held in the same struct as some of the data it contained,
    making it a self-referencial struct which the borrow checker doesn't
    allow.
    
    However, the only reason this buffer was held in the same struct was to
    reuse its allocation. This patch therefore creates a brand new vector
    every time we need to process data that contains references instead of
    cloned data. The expectation is that in the general case it's better to
    allocate a vector of references than clone a bunch of values.
    
    Signed-off-by: Petros Angelatos <[email protected]>
    petrosagg committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    f0dc750 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2021

  1. reduce: reuse the output buffer allocation

    This patch brings back the benefits of re-using the output buffer
    allocation at the cost of some unsafe code reasoning.
    
    Since the buffer is always cleared after each use we can simply store
    its type erased pointer and temporarily bring it back to its Vec form
    whenever there is some processing to do.
    
    Signed-off-by: Petros Angelatos <[email protected]>
    petrosagg committed Nov 20, 2021
    Configuration menu
    Copy the full SHA
    3d625d2 View commit details
    Browse the repository at this point in the history