From 9559ce33ebf536b8329a32c79e626f052349e157 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sat, 6 Feb 2016 07:48:57 +0100 Subject: [PATCH] remove linq search from deleteLQIs --- src/GraphicObjects/GraphicObject.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 6f565340..f6963cb5 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -111,7 +111,10 @@ namespace Crow #endregion #region ILayoutable - + /// + /// Keep ref's of LQI in queue per GraphicObject, to prevent searching in + /// the double linked list which would be very slow. + /// public List> RegisteredLQINodes { get; } = new List>(); //TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject // or we could add to the interface the mouse events @@ -501,12 +504,17 @@ namespace Crow protected virtual Size measureRawSize () { return Bounds.Size; } - + /// + /// Delete all ref's to this LQI (local and inQueue) + /// void deleteLQI(int lt){ - LinkedListNode[] lqis = this.RegisteredLQINodes.Where (n => (lt & (int)n.Value.LayoutType) > 0).ToArray (); - for (int i = 0; i < lqis.Length; i++) { - Interface.LayoutingQueue.Remove (lqis [i]); - RegisteredLQINodes.Remove (lqis [i]); + int i = 0; + while (i < RegisteredLQINodes.Count) { + if (((int)RegisteredLQINodes [i].Value.LayoutType & lt) > 0) { + Interface.LayoutingQueue.Remove (RegisteredLQINodes [i]); + RegisteredLQINodes.RemoveAt (i); + } else + i++; } } /// clear current layoutingQueue items for object and -- 2.47.3