You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Variant] Optimize the object header generation logic in ObjectBuilder::finish #7978
One thing I don't love about this approach is the independent calculation of the splice size vs. the bytes that actually get inserted. If they ever disagreed... badness as the insertions underflow or overflow the splice.
Ideally, we could produce an iterator that emits the desired bytes, and the splice itself can guarantee correct behavior. But for that to work the iterator would need to provide an accurate lower bound, so which rules out std::iter::from_fn. Even if we did craft a custom iterator, computing its lower bound would basically be this same calculation all over again. We could also chain together a bunch of iterators, which preserves the lower bound, but somehow I doubt that would be efficient.
Or try the other approach that populates the tmp vec with non-zero bytes before splicing it into the main buffer? That's a lot simpler than this iterator-based suggestion, and likely performs better too.
changed the title [-]Optimize the object header generation logic in ObjectBuilder::finish[/-][+][Variant] Optimize the object header generation logic in ObjectBuilder::finish[/+]on Jul 23, 2025
Activity
klion26 commentedon Jul 23, 2025
take
[-]Optimize the object header generation logic in ObjectBuilder::finish[/-][+][Variant] Optimize the object header generation logic in ObjectBuilder::finish[/+][Variant] Optimize the object header generation logic in ObjectBuilde…
[Variant] Optimize the object header generation logic in ObjectBuilde…