diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-06 07:48:57 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-02-06 07:48:57 +0100 |
| commit | 9559ce33ebf536b8329a32c79e626f052349e157 (patch) | |
| tree | e4169911ef1b7ea41e2a2c0cafcc89038a8c839c /src/GraphicObjects/GraphicObject.cs | |
| parent | bf2a27565631b8eaf29fd781befce937c59b43e3 (diff) | |
remove linq search from deleteLQIs
Diffstat (limited to 'src/GraphicObjects/GraphicObject.cs')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 20 |
1 files 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 - + /// <summary> + /// Keep ref's of LQI in queue per GraphicObject, to prevent searching in + /// the double linked list which would be very slow. + /// </summary> public List<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; } = new List<LinkedListNode<LayoutingQueueItem>>(); //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; } - + /// <summary> + /// Delete all ref's to this LQI (local and inQueue) + /// </summary> void deleteLQI(int lt){ - LinkedListNode<LayoutingQueueItem>[] 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++; } } /// <summary> clear current layoutingQueue items for object and |