Permalink
Browse files

this change seems safe as the two should be equivalent.and it doesnt

create an array on each
  • Loading branch information...
1 parent 6635977 commit 3a6207191d648eec1d366416b48277026ba977f1 @gregoryyoung gregoryyoung committed Mar 1, 2014
@@ -42,10 +42,9 @@ public class Murmur2Unsafe: IHasher
public unsafe UInt32 Hash(string s)
{
- var data = s.ToCharArray();
- fixed (char* input = &data[0])
+ fixed (char* input = s)
{
- return Hash((byte*)input, (uint)data.Length * sizeof(char), Seed);
+ return Hash((byte*)input, (uint)s.Length * sizeof(char), Seed);
}
}
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, Event Store LLP
+// Copyright (c) 2014, Event Store LLP
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -38,10 +38,9 @@ public class Murmur3AUnsafe : IHasher
public unsafe UInt32 Hash(string s)
{
- var data = s.ToCharArray();
- fixed (char* input = &data[0])
+ fixed (char* input = s)
{
- return Hash((byte*)input, (uint)data.Length * sizeof(char), Seed);
+ return Hash((byte*)input, (uint)s.Length * sizeof(char), Seed);
}
}
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, Event Store LLP
+// Copyright (c) 2014, Event Store LLP
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -41,10 +41,9 @@ public class XXHashUnsafe: IHasher
public unsafe UInt32 Hash(string s)
{
- var data = s.ToCharArray();
- fixed (char* input = &data[0])
+ fixed (char* input =s)
{
- return Hash((byte*) input, (uint) data.Length*sizeof (char), Seed);
+ return Hash((byte*) input, (uint) s.Length*sizeof (char), Seed);
}
}

0 comments on commit 3a62071

Please sign in to comment.