changeset 13:6b762694f051

Check size of dictionary so that we don't have to get the values when we've got an empty dictionary no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Jan 2009 19:27:47 +0000
parents 465b672e9682
children 25b953087465
files Collections/DictionaryToArrayConverter.cs
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Collections/DictionaryToArrayConverter.cs	Sun Jan 04 18:45:32 2009 +0000
+++ b/Collections/DictionaryToArrayConverter.cs	Tue Jan 06 19:27:47 2009 +0000
@@ -41,8 +41,14 @@
 				return null;
 			}
 			
-			VALUE_TYPE[] col = new VALUE_TYPE[dictionary.Count];
-			dictionary.Values.CopyTo(col, 0);
+			int entryCount = dictionary.Count;
+			VALUE_TYPE[] col = new VALUE_TYPE[entryCount];
+			
+			if (entryCount > 0)
+			{
+				dictionary.Values.CopyTo(col, 0);
+			}
+			
 			return col;
 		}
 	}