Created
June 24, 2016 01:47
-
-
Save sampaiodiego/6ef92f46896fb5167bd074da8683b9db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function v1(str) { | |
var hash = 5381; | |
for (i = 0; i <str.length; i++) { | |
char = str.charCodeAt(i); | |
hash = ((hash <<5) + hash) + char; /* hash * 33 + c */ | |
// hash = hash & hash; // Convert to 32bit integer | |
} | |
return hash; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment