Basic sanity checking in UUID.TryParse() to avoid throwing and catching exceptions for most failed parses. Improves the speed of UUID.TryParse() when false is returned

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3179 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2009-10-27 18:34:15 +00:00
parent c7b69243a5
commit e2aa580f7e

View File

@@ -218,7 +218,9 @@ namespace OpenMetaverse
/// <example>UUID.TryParse("11f8aa9c-b071-4242-836b-13b7abe0d489", result)</example>
public static bool TryParse(string val, out UUID result)
{
if (String.IsNullOrEmpty(val))
if (String.IsNullOrEmpty(val) ||
(val[0] == '{' && val.Length != 38) ||
(val.Length != 36 && val.Length != 32))
{
result = UUID.Zero;
return false;