* @brief Finds the first element in a range that matches a specified value. * * This function searches for the first element in the range `[base, base + num * size)` that is equal to `val` * based on the comparison function `comp`. * * @param base Pointer to the start of the array. * @param num Number of elements in the array. * @param size Size of each element in bytes. * @param val Point
| 290 | BoolPredicateFunc pred, ContextPredicateFunc cpred, void *ctx) { |
| 291 | size_t kept = 0; |
| 292 | for (size_t i = 0; i < num; i += 64) { |
| 293 | size_t m = (num - i < 64) ? num - i : 64; |
| 294 | const char *blk = src + i * sz; |
| 295 | uint64_t mask = 0; |
| 296 | for (size_t j = 0; j < m; ++j) { |
| 297 | const char *e = blk + j * sz; |
| 298 | int keep = (mode == 0) ? (pred(e) != 0) |
| 299 | : (mode == 1) ? (cpred(e, ctx) != 0) |
| 300 | : (mode == 3) ? (pred(e) == 0) |
| 301 | : alg_is_truthy(e, sz); |
| 302 | mask |= (uint64_t)keep << j; |
| 303 | } |
| 304 | uint64_t all = (m == 64) ? ~UINT64_C(0) : ((UINT64_C(1) << m) - 1); |
| 305 | if (mask == all && dst + kept * sz == blk) { |
| 306 | kept += m; /* in place and nothing dropped yet: nothing to move */ |
| 307 | continue; |
| 308 | } |
nothing calls this directly
no outgoing calls
no test coverage detected