From 6da88dceb0adb06c17f6f159824dabadc6634962 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Mon, 29 Jun 2009 16:55:00 +0000 Subject: * Changing List to Dictionary in PacketQueue.Dequeue for great justice (and performance) --- .../Region/ClientStack/LindenUDP/LLPacketQueue.cs | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 3844b1d..c19428d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP internal LLPacketThrottle TextureThrottle; internal LLPacketThrottle TotalThrottle; - private List contents = new List(); + private Dictionary contents = new Dictionary(); /// /// The number of packets in the OutgoingPacketQueue @@ -189,7 +189,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if (item.Sequence != 0) - lock (contents) contents.Add(item.Sequence); + lock (contents) + { + if (contents.ContainsKey(item.Sequence)) + contents[item.Sequence] += 1; + else + contents.Add(item.Sequence, 1); + } lock (this) { @@ -243,22 +249,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP return item; lock (contents) { - if (contents.Contains(item.Sequence)) - if (contents.Remove(item.Sequence)) - return item; + if (contents.ContainsKey(item.Sequence)) + { + if (contents[item.Sequence] == 1) + contents.Remove(item.Sequence); + else + contents[item.Sequence] -= 1; + return item; + } } } } public void Cancel(uint sequence) { - lock (contents) while (contents.Remove(sequence)) - ; + lock (contents) contents.Remove(sequence); } public bool Contains(uint sequence) { - lock (contents) return contents.Contains(sequence); + lock (contents) return contents.ContainsKey(sequence); } public void Flush() -- cgit v1.1