[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] esx: Remove 1000 lines of generated but unused code



On 05/01/2011 01:57 PM, Matthias Bolte wrote:
> Don't make all object and enum types (de)serializable by default.
> Detect this from the input file instead.
> ---
>  src/esx/esx_vi_generator.py |  167 +++++++++++++++++++++++++++++++-----------
>  1 files changed, 123 insertions(+), 44 deletions(-)

Too bad generated files don't show up in the diffstat :)

> +# there are two directions to spread features:
> +# 1) up and down the inheritance chain
> +# 2) from object types to their member property types
> +# spreading needs to be done alternating on both directions because they can
> +# affect each other
> +features_have_changed = True
> +
> +while features_have_changed:
> +    features_have_changed = False
> +
> +    for obj in objects_by_name.values():
> +        propagate_feature(obj, Object.FEATURE__DEEP_COPY)
> +        propagate_feature(obj, Object.FEATURE__SERIALIZE)
> +        propagate_feature(obj, Object.FEATURE__DESERIALIZE)
> +
> +    for obj in objects_by_name.values():
> +        inherit_features(obj)

If I'm reading this correctly, this looks like the core of the algorithm
- compute a closure of all features, and then only generate for where
the features were needed, rather than the old code that generated
features for everything whether it was needed or not.

My python is not very strong, but what you did was fairly readable and
seems to make sense.  At any rate, it compiles.

ACK.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]