Skip to content

Commit

Permalink
this change seems safe as the two should be equivalent.and it doesnt
Browse files Browse the repository at this point in the history
create an array on each
  • Loading branch information
gregoryyoung committed Mar 1, 2014
1 parent 6635977 commit 3a62071
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/EventStore/EventStore.Core/Index/Hashes/Murmur2Unsafe.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ public class Murmur2Unsafe: IHasher


public unsafe UInt32 Hash(string s) public unsafe UInt32 Hash(string s)
{ {
var data = s.ToCharArray(); fixed (char* input = s)
fixed (char* input = &data[0])
{ {
return Hash((byte*)input, (uint)data.Length * sizeof(char), Seed); return Hash((byte*)input, (uint)s.Length * sizeof(char), Seed);
} }
} }


Expand Down
7 changes: 3 additions & 4 deletions src/EventStore/EventStore.Core/Index/Hashes/Murmur3AUnsafe.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2012, Event Store LLP // Copyright (c) 2014, Event Store LLP
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -38,10 +38,9 @@ public class Murmur3AUnsafe : IHasher


public unsafe UInt32 Hash(string s) public unsafe UInt32 Hash(string s)
{ {
var data = s.ToCharArray(); fixed (char* input = s)
fixed (char* input = &data[0])
{ {
return Hash((byte*)input, (uint)data.Length * sizeof(char), Seed); return Hash((byte*)input, (uint)s.Length * sizeof(char), Seed);
} }
} }


Expand Down
7 changes: 3 additions & 4 deletions src/EventStore/EventStore.Core/Index/Hashes/XXHashUnsafe.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2012, Event Store LLP // Copyright (c) 2014, Event Store LLP
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,10 +41,9 @@ public class XXHashUnsafe: IHasher


public unsafe UInt32 Hash(string s) public unsafe UInt32 Hash(string s)
{ {
var data = s.ToCharArray(); fixed (char* input =s)
fixed (char* input = &data[0])
{ {
return Hash((byte*) input, (uint) data.Length*sizeof (char), Seed); return Hash((byte*) input, (uint) s.Length*sizeof (char), Seed);
} }
} }


Expand Down

0 comments on commit 3a62071

Please sign in to comment.