From f63f168b514532377eb96cb25573c4a1a6ea7baf Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Mon, 27 Jun 2016 00:29:27 -0700 Subject: [PATCH] Comment and simplify a bit of conversion There are ample opportunities to optimize and streamline here. For example, there's no reason to have a function to convert IntStr to IntStr. Removing the function does generate the right assignment, but it is unclear whether the registered function is needed or not. I opted to leave it alone for now. Another example is Convert_Slice_byte_To_Slice_byte, which just seems silly. --- cmd/libs/go2idl/conversion-gen/generators/conversion.go | 5 +++++ pkg/api/conversion.go | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/libs/go2idl/conversion-gen/generators/conversion.go b/cmd/libs/go2idl/conversion-gen/generators/conversion.go index 670a1bdb5ad..cfa62128b69 100644 --- a/cmd/libs/go2idl/conversion-gen/generators/conversion.go +++ b/cmd/libs/go2idl/conversion-gen/generators/conversion.go @@ -695,6 +695,11 @@ func (g *genConversion) doSlice(inType, outType *types.Type, sw *generator.Snipp funcName := g.funcNameTmpl(inType.Elem, outType.Elem) sw.Do(fmt.Sprintf("if err := %s(&(*in)[i], &(*out)[i], s); err != nil {\n", funcName), argsFromType(inType.Elem, outType.Elem)) } else { + // TODO: This triggers on v1.ObjectMeta <-> api.ObjectMeta and + // similar because neither package is the target package, and + // we really don't know which package will have the conversion + // function defined. This fires on basically every object + // conversion outside of pkg/api/v1. sw.Do("// TODO: Inefficient conversion - can we improve it?\n", nil) sw.Do("if err := s.Convert(&(*in)[i], &(*out)[i], 0); err != nil {\n", nil) } diff --git a/pkg/api/conversion.go b/pkg/api/conversion.go index 8a024a24b2b..07585d8c35e 100644 --- a/pkg/api/conversion.go +++ b/pkg/api/conversion.go @@ -100,15 +100,12 @@ func Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(in, out *unversioned.T } func Convert_unversioned_ListMeta_To_unversioned_ListMeta(in, out *unversioned.ListMeta, s conversion.Scope) error { - out.ResourceVersion = in.ResourceVersion - out.SelfLink = in.SelfLink + *out = *in return nil } func Convert_intstr_IntOrString_To_intstr_IntOrString(in, out *intstr.IntOrString, s conversion.Scope) error { - out.Type = in.Type - out.IntVal = in.IntVal - out.StrVal = in.StrVal + *out = *in return nil }