diff options
author | Ran Benita <ran234@gmail.com> | 2012-09-30 11:55:11 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2012-09-30 15:26:00 +0200 |
commit | 1c880887666f84e08ea1752bb8a5ab2a7bf1d8a0 (patch) | |
tree | df3c9d6dc0f27b5a0deb0fb26a973924ab610ca7 /src/text.h | |
parent | 26e685daaeeaa5fc1ac4166b2c066ed6fb4db930 (diff) |
Don't scan and parse useless maps
One physical xkb file may (and usually does) contain multiple maps. For
example, the us symbols file contains a map for every variant.
Currently, when we need a map from a file (specific or default), we
parse the entire file into a list of XkbFile's, find the map we want and
discard the others. This happens for every include statement. This is a lot
of unnecessary work; this commit is a first step at making it better.
What we do now is make yyparse return one map at a time; if we find what
we want, we can stop looking and avoid processing the rest of the file.
This moves some logic from include.c to parser.y (i.e. finding the
correct map, named or default). It also necessarily removes the
CheckDefaultMap check, which warned about a file which contains multiple
default maps. We can live without it.
Some stats with test/rulecomp (under valgrind and the benchmark):
Before:
==2280== total heap usage: 288,665 allocs, 288,665 frees, 13,121,349 bytes allocated
compiled 1000 keymaps in 10.849487353s
After:
==1070== total heap usage: 100,197 allocs, 100,197 frees, 9,329,900 bytes allocated
compiled 1000 keymaps in 5.258960549s
Pretty good.
Note: we still do some unnecessary work, by parsing and discarding the
maps before the one we want. However dealing with this is more
complicated (maybe using bison's push-parser and sniffing the token
stream). Probably not worth it.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/text.h')
0 files changed, 0 insertions, 0 deletions