Skip to content

Commit

Permalink
ICU-22419 Fix memory alignment for UTF-16 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Krechals committed Jun 22, 2023
1 parent c1883c8 commit 032a011
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions icu4c/source/i18n/rulebasedcollator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,21 +989,21 @@ RuleBasedCollator::doCompare(const char16_t *left, int32_t leftLength,
} else {
if ((uint32_t)leftLength >= sizeof(uint64_t)
&& (uint32_t)rightLength >= sizeof(uint64_t)
&& (uintptr_t)left % sizeof(uint64_t) == (uintptr_t)right % sizeof(uint64_t)) {
&& (uintptr_t)(const void*)left % sizeof(uint64_t) == (uintptr_t)(const void*)right % sizeof(uint64_t)) {
int32_t i = 0;
int32_t limit = leftLength < rightLength ? leftLength : rightLength;

// Memory alignment step.
while(i < limit && left[i] == right[i]
&& (uintptr_t)(left + i) % sizeof(uint64_t) != 0) {
&& ((uintptr_t)(const void*)(left + i)) % sizeof(uint64_t) != 0) {
++i;
}
equalPrefixLength += i;

// Double word baesd comparison.
if (i < limit && (uintptr_t)(left + i) % sizeof(uint64_t) == 0) {
const uint64_t *dWordLeft = (const uint64_t *)left;
const uint64_t *dWordRight = (const uint64_t *)right;
if (i < limit && (uintptr_t)(const void*)(left + i) % sizeof(uint64_t) == 0) {
const uint64_t *dWordLeft = (const uint64_t *)(const void *)left;
const uint64_t *dWordRight = (const uint64_t *)(const void *)right;
int32_t dWordLength = (leftLength < rightLength ? leftLength : rightLength) / sizeof(uint64_t);
i = 0;

Expand Down

0 comments on commit 032a011

Please sign in to comment.