Hash tables are definitely the way to go when data must be accessed from a large collection. But if the collection is very small (e.g. two strings), a simple if/else will be way faster.
Now I was wondering what I should do in my case. I have a collection of short strings (a dozen of characters in average) that depend on the user. In theory there could be 100 of them, but most of the times there will be around 2-5 strings in total. By most of the times I mean 99.9% of the times.
So I was wondering if anyone has thought about when using
GHashTable starts to be convenient compared to a loop of
strcmp(). Does it start to be convenient after 5 strings? After 20? After 100?
It is probably just a futile curiosity. Yet I am curious about it (also for future designs).