Skip to content
Snippets Groups Projects
  • Lioncash's avatar
    partition_data_manager: Reserve and insert data within output vector in DecryptPackage2() · 6467b01d
    Lioncash authored
    We can just reserve the memory then perform successive insertions
    instead of needing to use memcpy. This also avoids the need to zero out
    the output vector's memory before performing the insertions.
    
    We can also std::move the output std::vector into the destination so
    that we don't need to make a completely new copy of the vector, getting
    rid of an unnecessary allocation.
    
    Additionally, we can use iterators to determine the beginning and end
    ranges of the std::vector instances that comprise the output vector, as
    the end of one range just becomes the beginning for the next successive
    range, and since std::vector's iterator constructor copies data within
    the range [begin, end), this is more straightforward and gets rid of the
    need to have an offset variable that keeps getting incremented to
    determine where to do the next std::memcpy.
    6467b01d