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

Eric Blake eblake at redhat.com
Fri May 13 20:42:31 UTC 2011


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110513/f7c85839/attachment-0001.sig>


More information about the libvir-list mailing list