From 3eb5f84b4c6c40012a4f2257db34f5de7745ecaa Mon Sep 17 00:00:00 2001 From: Adriance <adriance@qq.com> Date: Wed, 19 Dec 2018 22:20:05 +0800 Subject: [PATCH] Modify the hash function --- js/jquery.multi-select.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index d71ca10..cc0f73b 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -486,15 +486,12 @@ }, sanitize: function(value){ - var hash = 0, i, character; - if (value.length == 0) return hash; - var ls = 0; - for (i = 0, ls = value.length; i < ls; i++) { - character = value.charCodeAt(i); - hash = ((hash<<5)-hash)+character; - hash |= 0; // Convert to 32bit integer + var hash = 5381, index = value.length; + while (index) { + hash = (hash * 33) ^ value.charCodeAt(--index); } - return hash; + + return hash >>> 0; } };