-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowing Go runtime compilation to succeed under ARM #1990
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,36 +353,37 @@ func PrintArrayJavaStyle(sa []string) string { | |
return buffer.String() | ||
} | ||
|
||
|
||
// murmur hash | ||
const ( | ||
c1_32 = 0xCC9E2D51 | ||
c2_32 = 0x1B873593 | ||
n1_32 = 0xE6546B64 | ||
c1_32 uint = 0xCC9E2D51 | ||
c2_32 uint = 0x1B873593 | ||
n1_32 uint = 0xE6546B64 | ||
) | ||
|
||
func murmurInit(seed int) int { | ||
return seed | ||
} | ||
|
||
func murmurUpdate(h1 int, k1 int) int { | ||
k1 *= c1_32 | ||
k1 = (k1 << 15) | (k1 >> 17) // rotl32(k1, 15) | ||
k1 *= c2_32 | ||
var k1u uint | ||
k1u = uint(k1) * c1_32 | ||
k1u = (k1u << 15) | (k1u >> 17) // rotl32(k1u, 15) | ||
k1u *= c2_32 | ||
|
||
h1 ^= k1 | ||
h1 = (h1 << 13) | (h1 >> 19) // rotl32(h1, 13) | ||
h1 = h1*5 + 0xe6546b64 | ||
return h1 | ||
var h1u = uint(h1) ^ k1u | ||
h1u = (h1u << 13) | (h1u >> 19) // rotl32(h1u, 13) | ||
h1u = h1u*5 + 0xe6546b64 | ||
return int(h1u) | ||
} | ||
|
||
func murmurFinish(h1 int, numberOfWords int) int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should fix the input type instead of relying on a cast (enforcing that there are no negative numbers passed to this function). Also might be good to document that numberOfWords is limited to be 4x less than the normal uint range. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started doing this but changing of the input arguments to uint percolates to many places, I don't have time to fix it at this moment, will push when it's ready There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont think it is needed. I did consider suggesting this option, then i checked alg specification, to my understanding h1 and k1 cannot be negative Wikipedia code FTW uint32_t murmur3_32(const uint8_t* key, size_t len, uint32_t seed) {
uint32_t h = seed;
if (len > 3) {
const uint32_t* key_x4 = (const uint32_t*) key;
size_t i = len >> 2;
do {
uint32_t k = *key_x4++;
k *= 0xcc9e2d51;
k = (k << 15) | (k >> 17);
k *= 0x1b873593;
h ^= k;
h = (h << 13) | (h >> 19);
h = (h * 5) + 0xe6546b64;
} while (--i);
key = (const uint8_t*) key_x4;
}
if (len & 3) {
size_t i = len & 3;
uint32_t k = 0;
key = &key[i - 1];
do {
k <<= 8;
k |= *key--;
} while (--i);
k *= 0xcc9e2d51;
k = (k << 15) | (k >> 17);
k *= 0x1b873593;
h ^= k;
}
h ^= len;
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
} |
||
h1 ^= (numberOfWords * 4) | ||
h1 ^= h1 >> 16 | ||
h1 *= 0x85ebca6b | ||
h1 ^= h1 >> 13 | ||
h1 *= 0xc2b2ae35 | ||
h1 ^= h1 >> 16 | ||
|
||
return h1 | ||
var h1u uint = uint(h1) | ||
h1u ^= uint(numberOfWords * 4) | ||
h1u ^= h1u >> 16 | ||
h1u *= uint(0x85ebca6b) | ||
h1u ^= h1u >> 13 | ||
h1u *= 0xc2b2ae35 | ||
h1u ^= h1u >> 16 | ||
|
||
return int(h1u) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid defining the var if you use the := operator. (Here and elsewhere.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK