From 1b1dfafc344ad7b60b8156a1bbdbfc1b364bfa98 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 13 Nov 2004 07:07:47 +0000 Subject: 2004-11-13 Havoc Pennington * test/glib/test-profile.c: fix this thing up a bit * dbus/dbus-message.c (dbus_message_new_empty_header): increase preallocation sizes by a fair bit; not sure if this will be an overall performance win or not, but it does reduce reallocs. * dbus/dbus-string.c (set_length, reallocate_for_length): ignore the test hack that forced constant realloc if asserts are disabled, so we can profile sanely. Sprinkle in some _DBUS_UNLIKELY() which are probably pointless, but before I noticed the real performance problem I put them in. (_dbus_string_validate_utf8): micro-optimize this thing a little bit, though callgrind says it didn't help; then special-case ascii, which did help a lot; then be sure we detect nul bytes as invalid, which is a bugfix. (align_length_then_lengthen): add some more _DBUS_UNLIKELY superstition; use memset to nul the padding instead of a manual loop. (_dbus_string_get_length): inline this as a macro; it showed up in the profile because it's used for loop tests and so forth --- dbus/dbus-string.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'dbus/dbus-string.h') diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h index 1a0236d4..cf526e43 100644 --- a/dbus/dbus-string.h +++ b/dbus/dbus-string.h @@ -49,6 +49,13 @@ struct DBusString unsigned int dummy8 : 3; /**< placeholder */ }; +/* Unless we want to run all the assertions in the function, + * inline this thing, it shows up high in the profile + */ +#ifdef DBUS_DISABLE_ASSERT +#define _dbus_string_get_length(s) ((s)->dummy2) +#endif + dbus_bool_t _dbus_string_init (DBusString *str); void _dbus_string_init_const (DBusString *str, const char *value); @@ -91,7 +98,10 @@ dbus_bool_t _dbus_string_copy_data_len (const DBusString *str, void _dbus_string_copy_to_buffer (const DBusString *str, char *buffer, int len); +#ifndef _dbus_string_get_length int _dbus_string_get_length (const DBusString *str); +#endif /* !_dbus_string_get_length */ + dbus_bool_t _dbus_string_lengthen (DBusString *str, int additional_length); void _dbus_string_shorten (DBusString *str, -- cgit