Changeset 2740 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Nov 18, 2002, 3:43:22 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r2736 r2740 665 665 return (l1 < l2) ? 1 : -1; 666 666 } 667 668 // Algorithm concept from Algorithms in C++, Sedgewick, Program 14.1. 669 int KJS::hash(const UString &s, int hashTableSize) 670 { 671 int h = 0; 672 int length = s.size(); 673 int prefix = length < 8 ? length : 8; 674 for (int i = 0; i != prefix; i++) 675 h = (127 * h + s[i].unicode()) % hashTableSize; 676 int suffix = length < 16 ? 8 : length - 8; 677 for (int i = suffix; i != length; i++) 678 h = (127 * h + s[i].unicode()) % hashTableSize; 679 return h; 680 }
Note:
See TracChangeset
for help on using the changeset viewer.