From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEa8i-0002yn-T7 for qemu-devel@nongnu.org; Mon, 13 Jul 2015 05:35:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEa8f-0003ko-J6 for qemu-devel@nongnu.org; Mon, 13 Jul 2015 05:35:08 -0400 Received: from mga01.intel.com ([192.55.52.88]:14590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEa8f-0003gD-Ex for qemu-devel@nongnu.org; Mon, 13 Jul 2015 05:35:05 -0400 From: Liang Li Date: Mon, 13 Jul 2015 17:34:10 +0800 Message-Id: <1436780050-25001-1-git-send-email-liang.z.li@intel.com> Subject: [Qemu-devel] [PATCH] migration: reduce the count of strlen call List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, Liang Li , dgilbert@redhat.com, quintela@redhat.com 'strlen' is called three times in 'save_page_header', it's inefficient. Signed-off-by: Liang Li --- migration/ram.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1e58cd3..7f007e6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -382,16 +382,16 @@ void migrate_compress_threads_create(void) */ static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t offset) { - size_t size; + size_t size, len; qemu_put_be64(f, offset); size = 8; if (!(offset & RAM_SAVE_FLAG_CONTINUE)) { - qemu_put_byte(f, strlen(block->idstr)); - qemu_put_buffer(f, (uint8_t *)block->idstr, - strlen(block->idstr)); - size += 1 + strlen(block->idstr); + len = strlen(block->idstr); + qemu_put_byte(f, len); + qemu_put_buffer(f, (uint8_t *)block->idstr, len); + size += 1 + len; } return size; } -- 1.9.1