In-place heapsort: deterministic byte order, no recursive stack or hidden * allocation, and request gates during comparisons and each extraction. */
| 1186 | /* In-place heapsort: deterministic byte order, no recursive stack or hidden |
| 1187 | * allocation, and request gates during comparisons and each extraction. */ |
| 1188 | static bool gf_inventory_sift(cbm_git_facts_t *facts, cbm_git_tree_entry_t *entries, size_t root, |
| 1189 | size_t count, cbm_git_facts_error_t *error) { |
| 1190 | while (root < count / 2) { |
| 1191 | size_t child = root * 2 + 1; |
| 1192 | int cmp; |
| 1193 | if (child + 1 < count) { |
| 1194 | if (!gf_inventory_compare(facts, &entries[child], &entries[child + 1], &cmp, error)) |
| 1195 | return false; |
| 1196 | if (cmp < 0) |
| 1197 | child++; |
| 1198 | } |
| 1199 | if (!gf_inventory_compare(facts, &entries[root], &entries[child], &cmp, error)) |
| 1200 | return false; |
| 1201 | if (cmp >= 0) |
| 1202 | return true; |
| 1203 | cbm_git_tree_entry_t swap = entries[root]; |
| 1204 | entries[root] = entries[child]; |
| 1205 | entries[child] = swap; |
| 1206 | root = child; |
| 1207 | } |
| 1208 | return true; |
| 1209 | } |
| 1210 | |
| 1211 | static bool gf_inventory_sort(cbm_git_facts_t *facts, cbm_git_tree_entry_t *entries, size_t count, |
| 1212 | cbm_git_facts_error_t *error) { |
no test coverage detected