* Read stdin line by line and print result of commands to stdout: * * perfhashmap method rounds -> test hashmap.[ch] performance * * NOTE: this is not used by any of our mechanized build & test * procedure, after 3469a236 (t: port helper/test-hashmap.c to * unit-tests/t-hashmap.c, 2024-08-03). See the log message of that * commit for the reason why this is still here. */
| 144 | * commit for the reason why this is still here. |
| 145 | */ |
| 146 | int cmd__hashmap(int argc UNUSED, const char **argv UNUSED) |
| 147 | { |
| 148 | struct string_list parts = STRING_LIST_INIT_NODUP; |
| 149 | struct strbuf line = STRBUF_INIT; |
| 150 | |
| 151 | /* process commands from stdin */ |
| 152 | while (strbuf_getline(&line, stdin) != EOF) { |
| 153 | char *cmd, *p1, *p2; |
| 154 | |
| 155 | /* break line into command and up to two parameters */ |
| 156 | string_list_setlen(&parts, 0); |
| 157 | string_list_split_in_place_f(&parts, line.buf, DELIM, 2, |
| 158 | STRING_LIST_SPLIT_NONEMPTY); |
| 159 | |
| 160 | /* ignore empty lines */ |
| 161 | if (!parts.nr) |
| 162 | continue; |
| 163 | if (!*parts.items[0].string || *parts.items[0].string == '#') |
| 164 | continue; |
| 165 | |
| 166 | cmd = parts.items[0].string; |
| 167 | p1 = parts.nr >= 1 ? parts.items[1].string : NULL; |
| 168 | p2 = parts.nr >= 2 ? parts.items[2].string : NULL; |
| 169 | |
| 170 | if (!strcmp("perfhashmap", cmd) && p1 && p2) { |
| 171 | |
| 172 | perf_hashmap(atoi(p1), atoi(p2)); |
| 173 | |
| 174 | } else { |
| 175 | |
| 176 | printf("Unknown command %s\n", cmd); |
| 177 | |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | string_list_clear(&parts, 0); |
| 182 | strbuf_release(&line); |
| 183 | return 0; |
| 184 | } |
nothing calls this directly
no test coverage detected