Closest member to this in a non-empty set. */
| 34 | |
| 35 | /* Closest member to this in a non-empty set. */ |
| 36 | static const char *closest(struct strset n, const char *member) |
| 37 | { |
| 38 | size_t len = strlen(member); |
| 39 | const u8 *bytes = (const u8 *)member; |
| 40 | |
| 41 | /* Anything with first byte 0 is a node. */ |
| 42 | while (!n.u.s[0]) { |
| 43 | u8 direction = 0; |
| 44 | |
| 45 | /* Special node which represents the empty string. */ |
| 46 | if (unlikely(n.u.n->byte_num == (size_t)-1)) { |
| 47 | n = n.u.n->child[0]; |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | if (n.u.n->byte_num < len) { |
| 52 | u8 c = bytes[n.u.n->byte_num]; |
| 53 | direction = (c >> n.u.n->bit_num) & 1; |
| 54 | } |
| 55 | n = n.u.n->child[direction]; |
| 56 | } |
| 57 | return n.u.s; |
| 58 | } |
| 59 | |
| 60 | char *strset_get(const struct strset *set, const char *member) |
| 61 | { |
no outgoing calls
no test coverage detected