Look up package name for a node ID in the parallel arrays. nids must be * sorted ascending (the node query orders by id) — a linear scan here is * O(E×N) across the edge loop and spun for >10 minutes on Linux-kernel-sized * graphs (~1.4M defs × ~1.4M CALLS edges). */
| 3913 | * O(E×N) across the edge loop and spun for >10 minutes on Linux-kernel-sized |
| 3914 | * graphs (~1.4M defs × ~1.4M CALLS edges). */ |
| 3915 | static const char *lookup_pkg(const int64_t *nids, char **npkgs, int nn, int64_t id) { |
| 3916 | int lo = 0; |
| 3917 | int hi = nn - SKIP_ONE; |
| 3918 | while (lo <= hi) { |
| 3919 | int mid = lo + (hi - lo) / PAIR_LEN; |
| 3920 | if (nids[mid] == id) { |
| 3921 | return npkgs[mid]; |
| 3922 | } |
| 3923 | if (nids[mid] < id) { |
| 3924 | lo = mid + SKIP_ONE; |
| 3925 | } else { |
| 3926 | hi = mid - SKIP_ONE; |
| 3927 | } |
| 3928 | } |
| 3929 | return NULL; |
| 3930 | } |
| 3931 | |
| 3932 | /* Accumulate a cross-package boundary into parallel arrays. */ |
| 3933 | static void accum_boundary(const char *src_pkg, const char *tgt_pkg, char **bfroms, char **btos, |