Received: from eggs.gnu.org ([2001:4830:134:3::10]:43310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHLP-0000Aa-4W for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:43:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFHLK-0003u1-4c for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:43:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFHLJ-0003tt-VZ for qemu-devel@nongnu.org; Wed, 15 Jul 2015 03:43:02 -0400 From: Juan Quintela In-Reply-To: <1436780050-25001-1-git-send-email-liang.z.li@intel.com> (Liang Li's message of "Mon, 13 Jul 2015 17:34:10 +0800") References: <1436780050-25001-1-git-send-email-liang.z.li@intel.com> Date: Wed, 15 Jul 2015 09:42:59 +0200 Message-ID: <87si8pdfy4.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] migration: reduce the count of strlen call Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liang Li Cc: amit.shah@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com Liang Li wrote: > 'strlen' is called three times in 'save_page_header', it's > inefficient. > > Signed-off-by: Liang Li Reviewed-by: Juan Quintela Applied > --- > 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; > }