[libvirt] [PATCH 06/22] esx_vi_generator: Simplify generate_helper_header

Daniel P. Berrangé berrange at redhat.com
Mon Mar 19 10:44:24 UTC 2018


On Sat, Mar 17, 2018 at 02:23:24PM +0000, Radostin Stoyanov wrote:
> The function generate_helper_header() only returns a formatted string.
> This could be achieved without performing string concatenation.
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
> ---
>  src/esx/esx_vi_generator.py | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
> index 19c225384..1641a2a1e 100755
> --- a/src/esx/esx_vi_generator.py
> +++ b/src/esx/esx_vi_generator.py
> @@ -1021,20 +1021,15 @@ class ManagedObject(GenericObject):
>  
>  
>      def generate_helper_header(self):
> -        header = ""
> -
>          # functions
> -        header += ("int esxVI_Lookup%s(esxVI_Context *ctx, "
> -                                      "const char *name, "
> -                                      "esxVI_ManagedObjectReference *root, "
> -                                      "esxVI_String *selectedPropertyNameList, "
> -                                      "esxVI_%s **item, "
> -                                      "esxVI_Occurrence occurrence);\n") \
> -                  % (self.name, self.name)
> -
> -        header += "\n"
> -
> -        return header
> +        return (
> +            "int esxVI_Lookup{name}(esxVI_Context *ctx, "
> +                                   "const char *name, "
> +                                   "esxVI_ManagedObjectReference *root, "
> +                                   "esxVI_String *selectedPropertyNameList, "
> +                                   "esxVI_{name} **item, "
> +                                   "esxVI_Occurrence occurrence);\n\n"
> +        ).format(name=self.name)

You're mixing two different changes in one patch here. First you're getting
rid of the string concatenation, but second you are changing the printf
format syntax used. Each change should be a distinct patch, but even better
is to not change the printf format at all.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list