From e2aa580f7e1c47725711ca5e5bbd21aa2b86610e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 27 Oct 2009 18:34:15 +0000 Subject: [PATCH] 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 --- OpenMetaverseTypes/UUID.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenMetaverseTypes/UUID.cs b/OpenMetaverseTypes/UUID.cs index 11cfc812..b7205508 100644 --- a/OpenMetaverseTypes/UUID.cs +++ b/OpenMetaverseTypes/UUID.cs @@ -218,7 +218,9 @@ namespace OpenMetaverse /// UUID.TryParse("11f8aa9c-b071-4242-836b-13b7abe0d489", result) 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;