Skip to content

Instantly share code, notes, and snippets.

@ypsu
ypsu / topfew.c
Last active July 13, 2020 19:41
// this is another mmap based topfew solution.
// context: https://www.tbray.org/ongoing/When/202x/2020/07/01/More-Topfew-Fun.
// other than the static hashmap, it doesn't use dynamic memory.
// rather than dynamically allocating strings for the hash keys,
// it just keeps pointers to the mmap'd data.
// it reparses the fields whenever it wants to compare two hash entries.
// compile like this: gcc -O2 topfew.c
// the following should be cmdline arguments
// but for the demo's simplicity let's just hardcode them: