diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 69a66e205a..af8b4c18aa 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1316,8 +1316,8 @@ namespace OpenSim.Framework public static UUID ComputeSHA1UUID(byte[] src) { byte[] ret; - using (SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider()) - ret = SHA1.ComputeHash(src); + using (SHA1 sha = SHA1.Create()) + ret = sha.ComputeHash(src); return new UUID(ret, 2); } @@ -1380,6 +1380,12 @@ namespace OpenSim.Framework return FieldToString(bytes, String.Empty); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string FieldToASCIIString(byte[] bytes, int limit) + { + return CleanString(Encoding.ASCII.GetString(bytes, 0, limit < bytes.Length ? limit : bytes.Length)); + } + /// /// Convert a variable length field (byte array) to a string, with a /// field name prepended to each line of the output @@ -2052,13 +2058,10 @@ namespace OpenSim.Framework public static string CleanString(string input) { - if (input.Length > 0) + for (int i = 0; i < input.Length; i++) { - for (int i = 0; i < input.Length; i++) - { - if (input[i] == '\0' || input[i] == '\r' || input[i] == '\n') - return input.Substring(0, i); - } + if (input[i] == '\0' || input[i] == '\r' || input[i] == '\n') + return input.Substring(0, i); } return input; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 05a2171597..0c193a1bac 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -185,11 +185,9 @@ namespace OpenSim.Region.ClientStack.Linden m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", m_enableFreeTestUpload); m_ForceFreeTestUpload = EconomyConfig.GetBoolean("ForceFreeTestUpload", m_ForceFreeTestUpload); string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", ""); - if (testcreator != "") + if (!string.IsNullOrEmpty(testcreator)) { - UUID id; - UUID.TryParse(testcreator, out id); - if (id != null) + if (UUID.TryParse(testcreator, out UUID id)) m_testAssetsCreatorID = id; } } @@ -198,19 +196,19 @@ namespace OpenSim.Region.ClientStack.Linden if (CapsConfig != null) { string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost"); - if(homeLocationUrl == String.Empty) + if(homeLocationUrl.Length == 0) m_AllowCapHomeLocation = false; string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost"); - if(GroupMemberDataUrl == String.Empty) + if(GroupMemberDataUrl.Length == 0) m_AllowCapGroupMemberData = false; string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost"); - if (LandResourcesUrl == String.Empty) + if (LandResourcesUrl.Length == 0) m_AllowCapLandResources = false; string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost"); - if (AttachmentResourcesUrl == String.Empty) + if (AttachmentResourcesUrl.Length == 0) m_AllowCapAttachmentResources = false; } } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEMeshWorker.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEMeshWorker.cs index 46d388b02b..4ed862ae6d 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEMeshWorker.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEMeshWorker.cs @@ -440,7 +440,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (pbs.SculptEntry) { - if (pbs.SculptTexture != null && !pbs.SculptTexture.IsZero()) + if (pbs.SculptTexture.IsNotZero()) { repData.assetID = pbs.SculptTexture; repData.meshState = MeshState.needAsset; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0c6c51e2ba..8054850d4a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6338,9 +6338,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetDate() { - DateTime date = DateTime.Now.ToUniversalTime(); - string result = date.ToString("yyyy-MM-dd"); - return result; + return DateTime.UtcNow.ToString("yyyy-MM-dd"); } public LSL_Integer llEdgeOfWorld(LSL_Vector pos, LSL_Vector dir) @@ -10983,7 +10981,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetTimestamp() { - return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); + return DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } public LSL_Integer llGetNumberOfPrims()