Using 'virJSONValueObjectHasKey' when we want to access the value
afterwards is wasteful. Fetch the JSON value right away.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
const char *tmp;
qemuMonitorCPUDefInfo *cpu = defs->cpus + i;
virJSONValue *feat;
+ virJSONValue *deprecated;
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
}
}
- if (virJSONValueObjectHasKey(child, "deprecated") &&
- virJSONValueObjectGetBoolean(child, "deprecated", &cpu->deprecated) < 0)
+ if ((deprecated = virJSONValueObjectGet(child, "deprecated")) &&
+ virJSONValueGetBoolean(deprecated, &cpu->deprecated) < 0)
return -1;
}