Browse Source
When we read the object header we copy 20 bytes from the pack data, then start parsing out the type and the inflated size. For most objects, this is only going to require 3 bytes, which is sufficient to represent objects with inflated sizes of up to 2^16. The local buffer however still has 17 bytes remaining in it, and that can be used to satisfy the OBJ_OFS_DELTA header. We shouldn't need to worry about walking off the end of the buffer here, because delta offsets cannot be larger than 64 bits, and that requires only 9 bytes in the OFS_DELTA encoding. Assuming worst-case scenarios of 9 bytes for the OFS_DELTA encoding, the pack file itself must be approaching 2^64 bytes, an infeasible size to store on any current technology. However, even if this were the case we still have 11 bytes for the type/size header. In that encoding we can represent an object as large as 2^74 bytes, which is also an infeasible size to process in JGit. So drop the second read here. The data offsets we pass into the ObjectLoaders being constructed need to be computed individually now. This saves a local variable, but pushes the addition operation into each branch of the switch. Change-Id: I6cf64697a9878db87bbf31c7636c03392b47a062 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>stable-0.8
Shawn O. Pearce
15 years ago
1 changed files with 7 additions and 11 deletions
Loading…
Reference in new issue