| 1163 | } |
| 1164 | |
| 1165 | static bool gf_inventory_compare(cbm_git_facts_t *facts, const cbm_git_tree_entry_t *a, |
| 1166 | const cbm_git_tree_entry_t *b, int *comparison, |
| 1167 | cbm_git_facts_error_t *error) { |
| 1168 | size_t common = a->path_length < b->path_length ? a->path_length : b->path_length; |
| 1169 | for (size_t at = 0; at < common;) { |
| 1170 | if (!gf_gate(facts, error)) |
| 1171 | return false; |
| 1172 | size_t chunk = common - at; |
| 1173 | if (chunk > 65536) |
| 1174 | chunk = 65536; |
| 1175 | int cmp = memcmp(a->path + at, b->path + at, chunk); |
| 1176 | if (cmp) { |
| 1177 | *comparison = cmp < 0 ? -1 : 1; |
| 1178 | return true; |
| 1179 | } |
| 1180 | at += chunk; |
| 1181 | } |
| 1182 | *comparison = a->path_length < b->path_length ? -1 : a->path_length > b->path_length ? 1 : 0; |
| 1183 | return true; |
| 1184 | } |
| 1185 | |
| 1186 | /* In-place heapsort: deterministic byte order, no recursive stack or hidden |
| 1187 | * allocation, and request gates during comparisons and each extraction. */ |
no test coverage detected