* Binary search to find the chunk that "where" is in. Note * that we're not looking for an exact match, just the first * chunk that contains it (which implicitly ends at the start * of the next chunk. */
| 1074 | * of the next chunk. |
| 1075 | */ |
| 1076 | static off_t find_reused_offset(off_t where) |
| 1077 | { |
| 1078 | int lo = 0, hi = reused_chunks_nr; |
| 1079 | while (lo < hi) { |
| 1080 | int mi = lo + ((hi - lo) / 2); |
| 1081 | if (where == reused_chunks[mi].original) |
| 1082 | return reused_chunks[mi].difference; |
| 1083 | if (where < reused_chunks[mi].original) |
| 1084 | hi = mi; |
| 1085 | else |
| 1086 | lo = mi + 1; |
| 1087 | } |
| 1088 | |
| 1089 | /* |
| 1090 | * The first chunk starts at zero, so we can't have gone below |
| 1091 | * there. |
| 1092 | */ |
| 1093 | assert(lo); |
| 1094 | return reused_chunks[lo-1].difference; |
| 1095 | } |
| 1096 | |
| 1097 | static void write_reused_pack_one(struct packed_git *reuse_packfile, |
| 1098 | size_t pos, struct hashfile *out, |
no outgoing calls
no test coverage detected