[libvirt] [PATCH 08/10] conf: use virXMLPropStringLimit where it makes sense

Pavel Hrdina posted 10 patches 8 years, 4 months ago
[libvirt] [PATCH 08/10] conf: use virXMLPropStringLimit where it makes sense
Posted by Pavel Hrdina 8 years, 4 months ago
The XPath call for these cases is more expensive than accessing the
XML dom node directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/conf/domain_conf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 83432fa5b0..ea293b9f02 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7227,8 +7227,8 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
     char *p;
     virSecurityLabelDefPtr seclabel = NULL;
 
-    p = virXPathStringLimit("string(./@model)",
-                            VIR_SECURITY_MODEL_BUFLEN - 1, ctxt);
+    p = virXMLPropStringLimit(ctxt->node, "model",
+                              VIR_SECURITY_MODEL_BUFLEN - 1);
 
     if (!(seclabel = virSecurityLabelDefNew(p)))
         goto error;
@@ -7237,8 +7237,8 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
     /* set default value */
     seclabel->type = VIR_DOMAIN_SECLABEL_DYNAMIC;
 
-    p = virXPathStringLimit("string(./@type)",
-                            VIR_SECURITY_LABEL_BUFLEN - 1, ctxt);
+    p = virXMLPropStringLimit(ctxt->node, "type",
+                              VIR_SECURITY_LABEL_BUFLEN - 1);
     if (p) {
         seclabel->type = virDomainSeclabelTypeFromString(p);
         if (seclabel->type <= 0) {
@@ -7253,8 +7253,8 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
         seclabel->relabel = false;
 
     VIR_FREE(p);
-    p = virXPathStringLimit("string(./@relabel)",
-                            VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
+    p = virXMLPropStringLimit(ctxt->node, "relabel",
+                              VIR_SECURITY_LABEL_BUFLEN-1);
     if (p) {
         if (STREQ(p, "yes")) {
             seclabel->relabel = true;
-- 
2.13.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/10] conf: use virXMLPropStringLimit where it makes sense
Posted by Ján Tomko 8 years, 4 months ago
On Wed, Aug 16, 2017 at 02:40:45PM +0200, Pavel Hrdina wrote:
>The XPath call for these cases is more expensive than accessing the
>XML dom node directly.
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/conf/domain_conf.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>

ACK

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list