This patch consists of two commits, which I intend to keep as separate commits. Both commits are cleanups without any functional changes.
The problem that these commits try to solve is that the ed_screen_context() function is now 700 lines long, and performs lots of string comparisons where a single hash lookup would suffice.
Split up ed_screen_context() into separate functions:
Refactor ed_screen_context() to call separate functions, instead of having the entire functionality in one function. Each function now only retrieves the data it needs from the context. Furthermore, some string comparisons are removed.
Refactor ed_screen_context() to use hash lookups:
Refactor ed_screen_context() to use hash lookups instead of a sequence of string comparisons. This should provide a nice speedup, given that the hash for member only has to be computed once instead of matching it to each possible string.
After this patch has been approved, it's my intention to look into the following:
- Convert to C++ to have a more powerful way to combine the definition and registration of callback functions.
- Refactor individual functions to be easier to read (less nesting, early returns).