Replace flex scanner with a hand-written one
authorRan Benita <ran234@gmail.com>
Sun, 12 Aug 2012 08:40:02 +0000 (11:40 +0300)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 1 Apr 2013 17:20:57 +0000 (18:20 +0100)
commita392d2682bfbf5ce6c3ee153c6a08bb456da0660
tree154727f033a8653a2cfa0a7fd861e15e742baa45
parente4bceec8809f2563af6786678442fa70d4cd728c
Replace flex scanner with a hand-written one

The scanner is very similar in structure to the one in xkbcomp/rules.c.
It avoids copying and has nicer error reporting.

It uses gperf to generate a hashtable for the keywords, which gives a
nice speed boost (compared to the naive strcasecmp method at least). But
since there's hardly a reason to regenerate it every time and require
people to install gperf, the output (keywords.c) is added here as well.

Here are some stats from test/rulescomp:

Before:
compiled 1000 keymaps in 4.052939625s
==22063==   total heap usage: 101,101 allocs, 101,101 frees, 11,840,834 bytes allocated

After:
compiled 1000 keymaps in 3.519665434s
==26505==   total heap usage: 99,945 allocs, 99,945 frees, 7,033,608 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
13 files changed:
Makefile.am
configure.ac
src/keymap.c
src/keymap.h
src/xkbcomp/.gitignore
src/xkbcomp/keywords.c [new file with mode: 0644]
src/xkbcomp/keywords.gperf [new file with mode: 0644]
src/xkbcomp/parser-priv.h
src/xkbcomp/parser.y
src/xkbcomp/scanner.c [new file with mode: 0644]
src/xkbcomp/scanner.l [deleted file]
src/xkbcomp/xkbcomp-priv.h
src/xkbcomp/xkbcomp.c