From: jpbruyere Date: Sat, 6 Feb 2016 05:28:01 +0000 (+0100) Subject: remove use of linq in binding resolution, replaced with Dictionnary X-Git-Tag: 0.3~46 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=8346912e89872501308e1526ca3ac04271153bb4;p=jp%2Fcrow.git remove use of linq in binding resolution, replaced with Dictionnary --- diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index fe010d6a..635dba9a 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -565,44 +565,12 @@ namespace Crow switch (layoutType) { case LayoutingType.Width: - if (Parent.getBounds ().Width < 0) { - Group gw = Parent as Group; - if (gw != null) { - if (Slot.Width > gw.maxChildrenWidth) - gw.maxChildrenWidth = Slot.Width; - } - this.Parent.RegisterForLayouting ((int)LayoutingType.Width); - }else if (Width != 0) //update position in parent + if (Width != 0 && Parent.getBounds().Width >=0) //update position in parent this.RegisterForLayouting ((int)LayoutingType.X); - GenericStack gsw = Parent as GenericStack; - if (gsw == null) - break; - if ((Parent as GenericStack).Orientation == Orientation.Horizontal) { -// ulong idx = (ulong)gsw.Children.IndexOf (this); -// if (idx < gsw.stackingUpdateStartIndex) -// gsw.stackingUpdateStartIndex = idx; - this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren); - } break; case LayoutingType.Height: - if (Parent.getBounds ().Height < 0) { - Group gh = Parent as Group; - if (gh != null) { - if (Slot.Width > gh.maxChildrenHeight) - gh.maxChildrenHeight = Slot.Height; - } - this.Parent.RegisterForLayouting ((int)LayoutingType.Height); - }else if (Height != 0) //update position in parent + if (Height != 0 && Parent.getBounds().Height >=0) //update position in parent this.RegisterForLayouting ((int)LayoutingType.Y); - GenericStack gsh = Parent as GenericStack; - if (gsh==null) - break; - if (gsh.Orientation == Orientation.Vertical) { -// ulong idx = (ulong)gsh.Children.IndexOf (this); -// if (idx < gsh.stackingUpdateStartIndex) -// gsh.stackingUpdateStartIndex = idx; - this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren); - } break; } LayoutChanged.Raise (this, new LayoutChangeEventArgs (layoutType)); @@ -901,7 +869,8 @@ namespace Crow #if DEBUG_BINDING Debug.WriteLine ("ResolveBinding => " + this.ToString ()); #endif - List resolved = new List (); + + Dictionary> resolved = new Dictionary>(); foreach (Binding b in Bindings) { if (!string.IsNullOrEmpty (b.DynMethodId)) continue; @@ -925,7 +894,12 @@ namespace Crow addHandler.Invoke (this, new object[] { del }); continue; } - resolved.Add (b); + List bindings = null; + if (!resolved.TryGetValue (b.Target.Instance, out bindings)) { + bindings = new List (); + resolved [b.Target.Instance] = bindings; + } + bindings.Add (b); } MethodInfo stringEquals = typeof(string).GetMethod @@ -941,8 +915,8 @@ namespace Crow //group;only one dynMethods by target (valuechanged event source) //changed value name tested in switch - IEnumerable groupedByTarget = resolved.GroupBy (g => g.Target.Instance, g => g, (k, g) => g.ToArray ()); - foreach (Binding[] grouped in groupedByTarget) { + //IEnumerable groupedByTarget = resolved.GroupBy (g => g.Target.Instance, g => g, (k, g) => g.ToArray ()); + foreach (List grouped in resolved.Values) { int i = 0; Type targetType = grouped[0].Target.Instance.GetType(); @@ -966,8 +940,8 @@ namespace Crow il = dm.GetILGenerator(256); endMethod = il.DefineLabel(); - jumpTable = new System.Reflection.Emit.Label[grouped.Length]; - for (i = 0; i < grouped.Length; i++) + jumpTable = new System.Reflection.Emit.Label[grouped.Count]; + for (i = 0; i < grouped.Count; i++) jumpTable [i] = il.DefineLabel (); il.DeclareLocal(typeof(string)); il.DeclareLocal(typeof(object));