From 3d9737442b97665aea1d03483f218806727a254d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 12 Jun 2014 11:36:51 +0200 Subject: [PATCH] libdm: dm_report_object avoid duplicat strlen call Remember strlen result. --- libdm/libdm-report.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index f3395a71a..820fa2a36 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -703,6 +703,7 @@ int dm_report_object(struct dm_report *rh, void *object) struct row *row; struct dm_report_field *field; void *data = NULL; + int len; if (!rh) { log_error(INTERNAL_ERROR "dm_report handler is NULL."); @@ -750,8 +751,9 @@ int dm_report_object(struct dm_report *rh, void *object) return 0; } - if (((int) strlen(field->report_string) > field->props->width)) - field->props->width = (int) strlen(field->report_string); + len = (int) strlen(field->report_string); + if (len > field->props->width) + field->props->width = len; if ((rh->flags & RH_SORT_REQUIRED) && (field->props->flags & FLD_SORT_KEY)) {