[maemo-commits] [maemo-commits] r15420 - in projects/haf/trunk/maemo-launcher: . launcher
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Apr 16 01:35:44 EEST 2008
- Previous message: [maemo-commits] r15419 - in projects/haf/trunk/maemo-launcher: . launcher
- Next message: [maemo-commits] r15421 - projects/haf/trunk/maemo-launcher
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: guillem Date: 2008-04-16 01:35:43 +0300 (Wed, 16 Apr 2008) New Revision: 15420 Modified: projects/haf/trunk/maemo-launcher/ChangeLog projects/haf/trunk/maemo-launcher/launcher/comm_msg.c Log: Optimize comm_msg_pack_int to not take into account unaligned memory Modified: projects/haf/trunk/maemo-launcher/ChangeLog =================================================================== --- projects/haf/trunk/maemo-launcher/ChangeLog 2008-04-15 22:35:42 UTC (rev 15419) +++ projects/haf/trunk/maemo-launcher/ChangeLog 2008-04-15 22:35:43 UTC (rev 15420) @@ -1,5 +1,12 @@ 2008-02-22 Guillem Jover <guillem.jover at nokia.com> + * launcher/comm_msg.c (comm_msg_pack_mem): Move code to ... + (comm_msg_pack_str): ... here. + (comm_msg_pack_int): Rewrite specialized version without taking into + account unaligned memory to improve performance. + +2008-02-22 Guillem Jover <guillem.jover at nokia.com> + * launcher/Makefile.am (check_PROGRAMS): Add 'test-msg-perf'. (test_msg_perf_SOURCES): New variable. (test_msg_perf_CPPFLAGS): Likewise. Modified: projects/haf/trunk/maemo-launcher/launcher/comm_msg.c =================================================================== --- projects/haf/trunk/maemo-launcher/launcher/comm_msg.c 2008-04-15 22:35:42 UTC (rev 15419) +++ projects/haf/trunk/maemo-launcher/launcher/comm_msg.c 2008-04-15 22:35:43 UTC (rev 15420) @@ -126,33 +126,6 @@ return true; } -static bool -comm_msg_pack_mem(comm_msg_t *msg, const void *buf, uint32_t size) -{ - uint32_t aligned_size = WORD_ALIGN(size); - uint32_t pad_size = aligned_size - size; - - if (!comm_msg_grow(msg, aligned_size + sizeof(uint32_t))) - return false; - - /* Pack the size. */ - memcpy(msg->buf + msg->used, &aligned_size, sizeof(uint32_t)); - msg->used += sizeof(uint32_t); - - /* Pack the data. */ - memcpy(msg->buf + msg->used, buf, size); - msg->used += size; - - if (pad_size) - { - /* Add padding, if needed. */ - memset(msg->buf + msg->used, 0, pad_size); - msg->used += pad_size; - } - - return true; -} - static const void * comm_msg_unpack_mem(comm_msg_t *msg, uint32_t *size) { @@ -184,7 +157,20 @@ bool comm_msg_pack_int(comm_msg_t *msg, uint32_t i) { - return comm_msg_pack_mem(msg, &i, sizeof(i)); + static const uint32_t size = sizeof(i); + + if (!comm_msg_grow(msg, size + sizeof(size))) + return false; + + /* Pack the size. */ + memcpy(msg->buf + msg->used, &size, sizeof(size)); + msg->used += sizeof(size); + + /* Pack the data. */ + memcpy(msg->buf + msg->used, &i, size); + msg->used += size; + + return true; } bool @@ -210,8 +196,28 @@ comm_msg_pack_str(comm_msg_t *msg, const char *str) { uint32_t size = strlen(str) + 1; + uint32_t aligned_size = WORD_ALIGN(size); + uint32_t pad_size = aligned_size - size; - return comm_msg_pack_mem(msg, str, size); + if (!comm_msg_grow(msg, aligned_size + sizeof(size))) + return false; + + /* Pack the size. */ + memcpy(msg->buf + msg->used, &aligned_size, sizeof(size)); + msg->used += sizeof(size); + + /* Pack the data. */ + memcpy(msg->buf + msg->used, str, size); + msg->used += size; + + if (pad_size) + { + /* Add padding, if needed. */ + memset(msg->buf + msg->used, 0, pad_size); + msg->used += pad_size; + } + + return true; } bool
- Previous message: [maemo-commits] r15419 - in projects/haf/trunk/maemo-launcher: . launcher
- Next message: [maemo-commits] r15421 - projects/haf/trunk/maemo-launcher
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]