MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / gf_inventory_sift

Function gf_inventory_sift

src/mcp/test_impact_git.c:1188–1209  ·  view source on GitHub ↗

In-place heapsort: deterministic byte order, no recursive stack or hidden * allocation, and request gates during comparisons and each extraction. */

Source from the content-addressed store, hash-verified

1186/* In-place heapsort: deterministic byte order, no recursive stack or hidden
1187 * allocation, and request gates during comparisons and each extraction. */
1188static 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
1211static 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) {

Callers 1

gf_inventory_sortFunction · 0.85

Calls 1

gf_inventory_compareFunction · 0.85

Tested by

no test coverage detected