From patchwork Mon Jul 13 09:34:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 494480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9703B1401E7 for ; Mon, 13 Jul 2015 19:35:29 +1000 (AEST) Received: from localhost ([::1]:53780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEa8z-0003IR-Sy for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2015 05:35:25 -0400 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 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 13 Jul 2015 02:35:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,461,1432623600"; d="scan'208";a="523346325" Received: from ll.sh.intel.com (HELO localhost) ([10.239.159.81]) by FMSMGA003.fm.intel.com with ESMTP; 13 Jul 2015 02:34:58 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Mon, 13 Jul 2015 17:34:10 +0800 Message-Id: <1436780050-25001-1-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Cc: amit.shah@redhat.com, Liang Li , dgilbert@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH] migration: reduce the count of strlen call X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 'strlen' is called three times in 'save_page_header', it's inefficient. Signed-off-by: Liang Li Reviewed-by: Amit Shah Reviewed-by: Juan Quintela --- 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; }