Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: source/common/ustring.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/ustrcase.cpp ('k') | source/common/ustrtrns.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * 3 *
4 * Copyright (C) 1998-2012, International Business Machines 4 * Copyright (C) 1998-2014, International Business Machines
5 * Corporation and others. All Rights Reserved. 5 * Corporation and others. All Rights Reserved.
6 * 6 *
7 ****************************************************************************** 7 ******************************************************************************
8 * 8 *
9 * File ustring.cpp 9 * File ustring.cpp
10 * 10 *
11 * Modification History: 11 * Modification History:
12 * 12 *
13 * Date Name Description 13 * Date Name Description
14 * 12/07/98 bertrand Creation. 14 * 12/07/98 bertrand Creation.
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 /* 1479 /*
1480 Compute the hash by iterating sparsely over about 32 (up to 63) 1480 Compute the hash by iterating sparsely over about 32 (up to 63)
1481 characters spaced evenly through the string. For each character, 1481 characters spaced evenly through the string. For each character,
1482 multiply the previous hash value by a prime number and add the new 1482 multiply the previous hash value by a prime number and add the new
1483 character in, like a linear congruential random number generator, 1483 character in, like a linear congruential random number generator,
1484 producing a pseudorandom deterministic value well distributed over 1484 producing a pseudorandom deterministic value well distributed over
1485 the output range. [LIU] 1485 the output range. [LIU]
1486 */ 1486 */
1487 1487
1488 #define STRING_HASH(TYPE, STR, STRLEN, DEREF) \ 1488 #define STRING_HASH(TYPE, STR, STRLEN, DEREF) \
1489 int32_t hash = 0; \ 1489 uint32_t hash = 0; \
1490 const TYPE *p = (const TYPE*) STR; \ 1490 const TYPE *p = (const TYPE*) STR; \
1491 if (p != NULL) { \ 1491 if (p != NULL) { \
1492 int32_t len = (int32_t)(STRLEN); \ 1492 int32_t len = (int32_t)(STRLEN); \
1493 int32_t inc = ((len - 32) / 32) + 1; \ 1493 int32_t inc = ((len - 32) / 32) + 1; \
1494 const TYPE *limit = p + len; \ 1494 const TYPE *limit = p + len; \
1495 while (p<limit) { \ 1495 while (p<limit) { \
1496 hash = (hash * 37) + DEREF; \ 1496 hash = (hash * 37) + DEREF; \
1497 p += inc; \ 1497 p += inc; \
1498 } \ 1498 } \
1499 } \ 1499 } \
1500 return hash 1500 return static_cast<int32_t>(hash)
1501 1501
1502 /* Used by UnicodeString to compute its hashcode - Not public API. */ 1502 /* Used by UnicodeString to compute its hashcode - Not public API. */
1503 U_CAPI int32_t U_EXPORT2 1503 U_CAPI int32_t U_EXPORT2
1504 ustr_hashUCharsN(const UChar *str, int32_t length) { 1504 ustr_hashUCharsN(const UChar *str, int32_t length) {
1505 STRING_HASH(UChar, str, length, *p); 1505 STRING_HASH(UChar, str, length, *p);
1506 } 1506 }
1507 1507
1508 U_CAPI int32_t U_EXPORT2 1508 U_CAPI int32_t U_EXPORT2
1509 ustr_hashCharsN(const char *str, int32_t length) { 1509 ustr_hashCharsN(const char *str, int32_t length) {
1510 STRING_HASH(uint8_t, str, length, *p); 1510 STRING_HASH(uint8_t, str, length, *p);
1511 } 1511 }
1512 1512
1513 U_CAPI int32_t U_EXPORT2 1513 U_CAPI int32_t U_EXPORT2
1514 ustr_hashICharsN(const char *str, int32_t length) { 1514 ustr_hashICharsN(const char *str, int32_t length) {
1515 STRING_HASH(char, str, length, (uint8_t)uprv_tolower(*p)); 1515 STRING_HASH(char, str, length, (uint8_t)uprv_tolower(*p));
1516 } 1516 }
OLDNEW
« no previous file with comments | « source/common/ustrcase.cpp ('k') | source/common/ustrtrns.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698