mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-12611 Fix some issues found through static analysis.
X-SVN-Rev: 38953
This commit is contained in:
parent
3f6aa90cdb
commit
10407c6184
4 changed files with 32 additions and 23 deletions
|
@ -236,9 +236,7 @@ class CharsetMBCS extends CharsetICU {
|
|||
throw new InvalidFormatException();
|
||||
}
|
||||
|
||||
data = new UConverterSharedData(1, null, false);
|
||||
data.staticData = staticData;
|
||||
data.sharedDataCached = false;
|
||||
data = new UConverterSharedData(1, staticData);
|
||||
|
||||
// Load data
|
||||
UConverterMBCSTable mbcsTable = data.mbcs;
|
||||
|
|
|
@ -28,19 +28,19 @@ final class UConverterSharedData {
|
|||
* pointer to the static (non changing)
|
||||
* data.
|
||||
*/
|
||||
UConverterStaticData staticData;
|
||||
final UConverterStaticData staticData;
|
||||
|
||||
// UBool sharedDataCached; /* TRUE: shared data is in cache, don't destroy
|
||||
// on close() if 0 ref. FALSE: shared data isn't in the cache, do attempt to
|
||||
// clean it up if the ref is 0 */
|
||||
|
||||
/**
|
||||
/*
|
||||
* TRUE: shared data is in cache, don't destroy
|
||||
* on close() if 0 ref. FALSE: shared data isn't
|
||||
* in the cache, do attempt to clean it up if
|
||||
* the ref is 0
|
||||
*/
|
||||
boolean sharedDataCached;
|
||||
//boolean sharedDataCached;
|
||||
|
||||
/*
|
||||
* UBool staticDataOwned; TRUE if static data owned by shared data & should
|
||||
|
@ -67,15 +67,14 @@ final class UConverterSharedData {
|
|||
CharsetMBCS.UConverterMBCSTable mbcs;
|
||||
|
||||
UConverterSharedData() {
|
||||
mbcs = new CharsetMBCS.UConverterMBCSTable();
|
||||
this(0, null);
|
||||
}
|
||||
|
||||
UConverterSharedData(int referenceCounter_, UConverterStaticData staticData_, boolean sharedDataCached_)
|
||||
UConverterSharedData(int referenceCounter_, UConverterStaticData staticData_)
|
||||
{
|
||||
this();
|
||||
mbcs = new CharsetMBCS.UConverterMBCSTable();
|
||||
referenceCounter = referenceCounter_;
|
||||
staticData = staticData_;
|
||||
sharedDataCached = sharedDataCached_;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,14 +39,24 @@ public final class FCDUTF16CollationIterator extends UTF16CollationIterator {
|
|||
@Override
|
||||
public boolean equals(Object other) {
|
||||
// Skip the UTF16CollationIterator and call its parent.
|
||||
if(!((CollationIterator)this).equals(other)) { return false; }
|
||||
if (!(other instanceof CollationIterator)
|
||||
|| !((CollationIterator)this).equals(other)
|
||||
|| !(other instanceof FCDUTF16CollationIterator))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
FCDUTF16CollationIterator o = (FCDUTF16CollationIterator)other;
|
||||
// Compare the iterator state but not the text: Assume that the caller does that.
|
||||
if(checkDir != o.checkDir) { return false; }
|
||||
if(checkDir == 0 && (seq == rawSeq) != (o.seq == o.rawSeq)) { return false; }
|
||||
if(checkDir != 0 || seq == rawSeq) {
|
||||
if (checkDir != o.checkDir) {
|
||||
return false;
|
||||
}
|
||||
if (checkDir == 0 && (seq == rawSeq) != (o.seq == o.rawSeq)) {
|
||||
return false;
|
||||
}
|
||||
if (checkDir != 0 || seq == rawSeq) {
|
||||
return (pos - rawStart) == (o.pos - /*o.*/ rawStart);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return (segmentStart - rawStart) == (o.segmentStart - /*o.*/ rawStart) &&
|
||||
(pos - start) == (o.pos - o.start);
|
||||
}
|
||||
|
|
|
@ -261,9 +261,7 @@ public class TimeZoneGenericNames implements Serializable, Freezable<TimeZoneGen
|
|||
String tmp = _genericLocationNamesMap.putIfAbsent(canonicalTzID, name.intern());
|
||||
if (tmp == null) {
|
||||
// Also put the name info the to trie
|
||||
NameInfo info = new NameInfo();
|
||||
info.tzID = canonicalTzID;
|
||||
info.type = GenericNameType.LOCATION;
|
||||
NameInfo info = new NameInfo(canonicalTzID, GenericNameType.LOCATION);
|
||||
_gnamesTrie.put(name, info);
|
||||
} else {
|
||||
name = tmp;
|
||||
|
@ -572,9 +570,8 @@ public class TimeZoneGenericNames implements Serializable, Freezable<TimeZoneGen
|
|||
synchronized (this) { // we have to sync the name map and the trie
|
||||
String tmp = _genericPartialLocationNamesMap.putIfAbsent(key.intern(), name.intern());
|
||||
if (tmp == null) {
|
||||
NameInfo info = new NameInfo();
|
||||
info.tzID = tzID.intern();
|
||||
info.type = isLong ? GenericNameType.LONG : GenericNameType.SHORT;
|
||||
NameInfo info = new NameInfo(tzID.intern(),
|
||||
isLong ? GenericNameType.LONG : GenericNameType.SHORT);
|
||||
_gnamesTrie.put(name, info);
|
||||
} else {
|
||||
name = tmp;
|
||||
|
@ -587,8 +584,13 @@ public class TimeZoneGenericNames implements Serializable, Freezable<TimeZoneGen
|
|||
* A private class used for storing the name information in the local trie.
|
||||
*/
|
||||
private static class NameInfo {
|
||||
String tzID;
|
||||
GenericNameType type;
|
||||
final String tzID;
|
||||
final GenericNameType type;
|
||||
|
||||
NameInfo(String tzID, GenericNameType type) {
|
||||
this.tzID = tzID;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue