mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-7264 fix binary search and avoid IndexOutOfBoundsException from ArrayList.get(limit=size())
X-SVN-Rev: 28903
This commit is contained in:
parent
583f5ab6ee
commit
e6751083f6
1 changed files with 15 additions and 16 deletions
|
@ -2204,23 +2204,22 @@ final class CollationParsedRuleBuilder {
|
|||
// using binary search to determine if last expansion element is
|
||||
// already in the array
|
||||
int result = -1;
|
||||
while (start < limit - 1) {
|
||||
int mid = start + ((limit - start) >> 1);
|
||||
long unsignedce = (maxexpansion.m_endExpansionCE_
|
||||
.get(mid)).intValue();
|
||||
unsignedce &= 0xFFFFFFFFl;
|
||||
if (unsigned <= unsignedce) {
|
||||
limit = mid;
|
||||
} else {
|
||||
start = mid;
|
||||
if (limit > 0) {
|
||||
while (start < limit - 1) {
|
||||
int mid = (start + limit) >> 1;
|
||||
long unsignedce = (maxexpansion.m_endExpansionCE_
|
||||
.get(mid)).intValue();
|
||||
unsignedce &= 0xFFFFFFFFl;
|
||||
if (unsigned < unsignedce) {
|
||||
limit = mid;
|
||||
} else {
|
||||
start = mid;
|
||||
}
|
||||
}
|
||||
|
||||
if ((maxexpansion.m_endExpansionCE_.get(start)).intValue() == endexpansion) {
|
||||
result = start;
|
||||
}
|
||||
}
|
||||
|
||||
if ((maxexpansion.m_endExpansionCE_.get(start)).intValue() == endexpansion) {
|
||||
result = start;
|
||||
} else if ((maxexpansion.m_endExpansionCE_.get(limit))
|
||||
.intValue() == endexpansion) {
|
||||
result = limit;
|
||||
}
|
||||
if (result > -1) {
|
||||
// found the ce in expansion, we'll just modify the size if it
|
||||
|
|
Loading…
Add table
Reference in a new issue