[elinks-dev] Options initialization and caching

Witold Filipczyk witekfl at poczta.gazeta.pl
Sat Oct 25 04:41:29 PDT 2003


When options are stored in struct options[] table elinks will be faster
and smaller.  Instead of calling get_opt_rec for every record options
should be in table initialized at compile time. Most calls 'get_opt_rec'
should be replaced by macro which resolve 'symbol' at compilation time.
Small example give more light on this subject.

enum options_numbers {
BOOKMARKS,
BOOKMARKS_FILE_FORMAT
CONFIG,
CONFIG_COMMENTS,
CONFIG_INDENTATION,
...
}

struct options opts[] = {
	(prev), (next), "bookmarks", 0, OPT_TREE, (min), (max), ...
	... 
}

Macro could looks like this
#define get_opt_int(OPTION_NUMBER)  opts[(OPTION_NUMBER)].value.number
or something like that and used like this
get_opt_int(CONFIG_INDENTATION)

I hope you got it!

Table opts[] should be filled in such way, that get_opt_rec is working
right on it.

I hope that you see that this could make elinks smaller and faster,
but don't ask me to code it.
-- 
Witold Filipczyk tohu-bohu
<witekfl at poczta.gazeta.pl>



More information about the elinks-dev mailing list