forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash.js
More file actions
21 lines (21 loc) · 645 Bytes
/
Copy pathhash.js
File metadata and controls
21 lines (21 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Object.assign(pc, (function () {
return {
/**
* @private
* @function
* @name pc.hashCode
* @description Calculates simple hash value of a string. Designed for performance, not perfect.
* @param {String} str String
* @returns {Number} Hash value
*/
hashCode: function (str) {
var hash = 0;
for (var i = 0, len = str.length; i < len; i++) {
hash = ((hash << 5) - hash) + str.charCodeAt(i);
// Convert to 32bit integer
hash |= 0;
}
return hash;
}
};
}()));