Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* hash function; Author PaulCodeman */
  2.  
  3.  
  4. /*
  5. String.prototype.hashCode = function() {
  6.   var hash = 0, i, chr;
  7.   if (this.length === 0) return hash;
  8.   for (i = 0; i < this.length; i++) {
  9.     chr   = this.charCodeAt(i);
  10.     hash  = ((hash << 5) - hash) + chr;
  11.     hash |= 0; // Convert to 32bit integer
  12.   }
  13.   return hash;
  14. };
  15. */
  16.  
  17. inline dword hashCode(dword data, length)
  18. {
  19.         dword hash = 0;
  20.         WHILE (length)
  21.         {
  22.                 hash = hash << 5 - hash + DSBYTE[data];
  23.                 data++;
  24.                 length--;
  25.         }
  26.         RETURN hash;
  27. }
  28.