japanoise / emsys

ersatz-emacs text editor
MIT License
3 stars 2 forks source link

Why uthash? #33

Closed nicholascarroll closed 1 month ago

nicholascarroll commented 1 month ago

emsys only uses uthash.h for command lookup in command.c. While uthash is a powerful and efficient hash table implementation, it may be overkill unless its planned to be used for something else?

@japanoise would you be interested in getting a PR to replace uthash with a simple sorted array of commands and using binary search for lookups?

cheers

japanoise commented 1 month ago

emsys is loosely based on two sources - the "Build Your Own Text Editor" tutorial, and my earlier project, gomacs. gomacs, being a Go program, has a map to lookup its commands since maps are built into Go and thus that's easy enough to do. Out of laziness and the uthash interface being pretty decent, I went ahead and did the same thing for emsys using uthash.

There's really no reason we can't go ahead and do a binary search for commands instead of uthash. There won't be loads and loads of commands. And I don't think we'll need the map interface for anything else atm. So if you want to go ahead and take care of that, no objections.

nicholascarroll commented 1 month ago

cool

nicholascarroll commented 1 month ago

I've got this in my branch visual-mark. will be my next PR

japanoise commented 1 month ago

Fixed in your PR.