[Xcb-commit] atom
Jamey Sharp
jamey at kemper.freedesktop.org
Sat May 12 20:30:36 PDT 2007
atom/atoms.gperf.m4 | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
New commits:
diff-tree 7d14b6da242f760af33a15c169bb0c301f78ac22 (from 4b19fe81d7e5281eec3a8e17f8f5c4fbfa704aab)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date: Fri May 11 18:16:25 2007 +0200
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 at minilop.net>
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_co
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)
More information about the xcb-commit
mailing list