From nobody Mon Feb 9 10:57:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669912330; cv=none; d=zohomail.com; s=zohoarc; b=cF45ZnQgJRxqaMwE6jgtomIhZ2CJROcwQXNfaG+GSq0gdxpF/VJ4N2+5JE2IuzSG9hOm02j7sIiv4p92PWtQ7EqWxJMsrwyqZGa7AqFgdxdJf/ouzPelb61mwxjfT3HqJ6Yq9MOAPQwhMXAV1tHb6m0t3OxtiB07HoudVIp4b9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669912330; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LQehEA70EqaJahF2KpvaAF8CY4FFkAS8kU0q2gJest4=; b=Sp1D1axJ0y0JGrW+31ooeGzXOxc+JpC+9mVLb5d8DL6WrPmV/FnrlXg8HF607KwI8d+0KGk8THicMk93SJtCpAjm0Jyg2Jlsaaz3vmffw18E2c36kKSV5+SJbarJF3LrU4937VpMt0fEIPXHYzmVTDUyg5VklU05o79QzpAsA+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 166991233062180.61817593714522; Thu, 1 Dec 2022 08:32:10 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-e9mGAXP6OB6JehP3jy7kPw-1; Thu, 01 Dec 2022 11:31:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 584A93C0F235; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 410D71401C31; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 24FF019465A8; Thu, 1 Dec 2022 16:31:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 577C619465A8 for ; Thu, 1 Dec 2022 16:31:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4D532C1908D; Thu, 1 Dec 2022 16:31:27 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A655EC15BB4 for ; Thu, 1 Dec 2022 16:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669912328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LQehEA70EqaJahF2KpvaAF8CY4FFkAS8kU0q2gJest4=; b=i1a3zI8E1JUnVg/Jcl1D03hFDjDy7E8ze0Von88Rq1T09T4x8wO561Ja94swRT6odVgGsm Fnp4pf75nKyhYVBAcbZy23uSugcu3wpsQZ3QYzk3ZXySGH72/LvIvW9gfqvsWIsnHndJAU xgJnVraRJW3NIvl7O4Ibk9NuEVuaTEE= X-MC-Unique: e9mGAXP6OB6JehP3jy7kPw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/12] qemuMonitorJSONGetCPUDefinitions: Avoid double lookup of object Date: Thu, 1 Dec 2022 17:31:13 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669912331103100003 Content-Type: text/plain; charset="utf-8" Using 'virJSONValueObjectHasKey' when we want to access the value afterwards is wasteful. Fetch the JSON value right away. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cbd1eb6eec..1deb755130 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4842,6 +4842,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, const char *tmp; qemuMonitorCPUDefInfo *cpu =3D defs->cpus + i; virJSONValue *feat; + virJSONValue *deprecated; if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4865,8 +4866,8 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, } } - if (virJSONValueObjectHasKey(child, "deprecated") && - virJSONValueObjectGetBoolean(child, "deprecated", &cpu->deprec= ated) < 0) + if ((deprecated =3D virJSONValueObjectGet(child, "deprecated")) && + virJSONValueGetBoolean(deprecated, &cpu->deprecated) < 0) return -1; } --=20 2.38.1