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

Various serialization simplifcations and optimizations #9039

Merged
merged 9 commits into from Nov 9, 2016

Commits on Nov 7, 2016

  1. Remove unused ReadVersion and WriteVersion

    CDataStream and CAutoFile had a ReadVersion and WriteVersion method
    that was never used. Remove them.
    sipa committed Nov 7, 2016
    1 Configuration menu
    Copy the full SHA
    50e8a9c View commit details
    Browse the repository at this point in the history
  2. Make streams' read and write return void

    The stream implementations had two cascading layers (the upper one
    with operator<< and operator>>, and a lower one with read and write).
    The lower layer's functions are never cascaded (nor should they, as
    they should only be used from the higher layer), so make them return
    void instead.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    c2c5d42 View commit details
    Browse the repository at this point in the history
  3. Make nType and nVersion private and sometimes const

    Make the various stream implementations' nType and nVersion private
    and const (except in CDataStream where we really need a setter).
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    fad9b66 View commit details
    Browse the repository at this point in the history
  4. Make GetSerializeSize a wrapper on top of CSizeComputer

    Given that in default GetSerializeSize implementations created by
    ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
    of the specialized GetSerializeSize methods everywhere, and just use
    CSizeComputer. This removes a lot of code which isn't actually used
    anywhere.
    
    For CCompactSize and CVarInt this actually removes a more efficient
    size computing algorithm, which is brought back in a later commit.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    657e05a View commit details
    Browse the repository at this point in the history
  5. Get rid of nType and nVersion

    Remove the nType and nVersion as parameters to all serialization methods
    and functions. There is only one place where it's read and has an impact
    (in CAddress), and even there it does not impact any of the recursively
    invoked serializers.
    
    Instead, the few places that need nType or nVersion are changed to read
    it directly from the stream object, through GetType() and GetVersion()
    methods which are added to all stream classes.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    5284721 View commit details
    Browse the repository at this point in the history
  6. Avoid -Wshadow errors

    Suggested by Pavel Janik.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    a603925 View commit details
    Browse the repository at this point in the history
  7. Make CSerAction's ForRead() constexpr

    The CSerAction's ForRead() method does not depend on any runtime
    data, so guarantee that requests to it can be optimized out by
    making it constexpr.
    
    Suggested by Cory Fields.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    a2929a2 View commit details
    Browse the repository at this point in the history
  8. Add optimized CSizeComputer serializers

    To get the advantages of faster GetSerializeSize() implementations
    back that were removed in "Make GetSerializeSize a wrapper on top of
    CSizeComputer", reintroduce them in the few places in the form of a
    specialized Serialize() implementation. This actually gets us in a
    better state than before, as these even get used when they're invoked
    indirectly in the serialization of another object.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    25a211a View commit details
    Browse the repository at this point in the history
  9. Use fixed preallocation instead of costly GetSerializeSize

    Dbwrapper used GetSerializeSize() to compute the size of the buffer
    to preallocate. For some cases (specifically: CCoins) this requires
    a costly compression call. Avoid this by just using fixed size
    preallocations instead.
    sipa committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    d59a518 View commit details
    Browse the repository at this point in the history