summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilman Sauerbeck <tilman@code-monkey.de>2007-05-11 18:16:25 +0200
committerJamey Sharp <jamey@minilop.net>2007-05-12 20:30:00 -0700
commitf1ff8e4b2998d2f1eee1f87228aa4197807111d0 (patch)
tree9d8151601d56de2203a7c79fbb62657bf48ca5f0
parent7a808b48a01c9460c8d30b031e431455984b3ce1 (diff)
atom: Replace 'char *atom_names[]' with one big string and array of offsets.
This reduces the memory footprint of libxcb-atom.so, and the number of relocations that have to be performed on load. before: atom/.libs/libxcb-atom.so: 73 relocations text data bss dec hex filename 9587 588 132 10307 2843 atom/.libs/libxcb-atom.so after: atom/.libs/libxcb-atom.so: 5 relocations text data bss dec hex filename 9183 316 132 9631 259f atom/.libs/libxcb-atom.so Signed-off-by: Jamey Sharp <jamey@minilop.net>
-rw-r--r--atom/atoms.gperf.m414
1 files changed, 10 insertions, 4 deletions
diff --git a/atom/atoms.gperf.m4 b/atom/atoms.gperf.m4
index 9554972..ec733de 100644
--- a/atom/atoms.gperf.m4
+++ b/atom/atoms.gperf.m4
@@ -22,8 +22,14 @@ define(`COUNT', 0)dnl
define(`DO', `$1,define(`COUNT', incr(COUNT))COUNT')dnl
include(atomlist.m4)`'dnl
%%
-static const char *const atom_names[] = {
-define(`DO', ` "$1",')dnl
+
+static const char atom_names[] =
+define(`DO', ` "$1\0"')dnl
+include(atomlist.m4);
+
+static const uint16_t atom_name_offsets[] = {
+define(`OFFSET', 0)dnl
+define(`DO', ` OFFSET,define(`OFFSET', eval(OFFSET+1+len($1)))')dnl
include(atomlist.m4)`'dnl
};
@@ -76,9 +82,9 @@ xcb_atom_t intern_atom_fast_reply(xcb_connection_t *c, intern_atom_fast_cookie_t
const char *get_atom_name_predefined(xcb_atom_t atom)
{
- if(atom <= 0 || atom > (sizeof(atom_names) / sizeof(*atom_names)))
+ if(atom <= 0 || atom > (sizeof(atom_name_offsets) / sizeof(*atom_name_offsets)))
return 0;
- return atom_names[atom - 1];
+ return atom_names + atom_name_offsets[atom - 1];
}
int get_atom_name(xcb_connection_t *c, xcb_atom_t atom, const char **namep, int *lengthp)