Skip to content

Commit 0bf8a95

Browse files
committed
ICU-22793 Remove superfluous return value typecasts to UBool.
1 parent 07e0f7e commit 0bf8a95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+133
-138
lines changed

icu4c/source/common/bmpset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ BMPSet::contains(UChar32 c) const {
293293
if (static_cast<uint32_t>(c) <= 0xff) {
294294
return latin1Contains[c];
295295
} else if (static_cast<uint32_t>(c) <= 0x7ff) {
296-
return static_cast<UBool>((table7FF[c & 0x3f] & (static_cast<uint32_t>(1) << (c >> 6))) != 0);
296+
return (table7FF[c & 0x3f] & (static_cast<uint32_t>(1) << (c >> 6))) != 0;
297297
} else if (static_cast<uint32_t>(c) < 0xd800 || (c >= 0xe000 && c <= 0xffff)) {
298298
int lead=c>>12;
299299
uint32_t twoBits=(bmpBlockBits[(c>>6)&0x3f]>>lead)&0x10001;
300300
if(twoBits<=1) {
301301
// All 64 code points with the same bits 15..6
302302
// are either in the set or not.
303-
return static_cast<UBool>(twoBits);
303+
return twoBits;
304304
} else {
305305
// Look up the code point in its 4k block of code points.
306306
return containsSlow(c, list4kStarts[lead], list4kStarts[lead+1]);

icu4c/source/common/bmpset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class BMPSet : public UMemory {
156156
};
157157

158158
inline UBool BMPSet::containsSlow(UChar32 c, int32_t lo, int32_t hi) const {
159-
return static_cast<UBool>(findCodePoint(c, lo, hi) & 1);
159+
return findCodePoint(c, lo, hi) & 1;
160160
}
161161

162162
U_NAMESPACE_END

icu4c/source/common/normalizer2impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class U_COMMON_API Normalizer2Impl : public UObject {
364364
// 0<=lead<=0xffff
365365
uint8_t bits=smallFCD[lead>>8];
366366
if(bits==0) { return false; }
367-
return static_cast<UBool>((bits >> ((lead >> 5) & 7)) & 1);
367+
return (bits >> ((lead >> 5) & 7)) & 1;
368368
}
369369
/** Returns the FCD value from the regular normalization data. */
370370
uint16_t getFCD16FromNormData(UChar32 c) const;

icu4c/source/common/patternprops.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ PatternProps::isSyntax(UChar32 c) {
120120
if(c<0) {
121121
return false;
122122
} else if(c<=0xff) {
123-
return static_cast<UBool>(latin1[c] >> 1) & 1;
123+
return (latin1[c] >> 1) & 1;
124124
} else if(c<0x2010) {
125125
return false;
126126
} else if(c<=0x3030) {
127127
uint32_t bits=syntax2000[index2000[(c-0x2000)>>5]];
128-
return static_cast<UBool>((bits >> (c & 0x1f)) & 1);
128+
return (bits >> (c & 0x1f)) & 1;
129129
} else if(0xfd3e<=c && c<=0xfe46) {
130130
return c<=0xfd3f || 0xfe45<=c;
131131
} else {
@@ -138,12 +138,12 @@ PatternProps::isSyntaxOrWhiteSpace(UChar32 c) {
138138
if(c<0) {
139139
return false;
140140
} else if(c<=0xff) {
141-
return static_cast<UBool>(latin1[c] & 1);
141+
return latin1[c] & 1;
142142
} else if(c<0x200e) {
143143
return false;
144144
} else if(c<=0x3030) {
145145
uint32_t bits=syntaxOrWhiteSpace2000[index2000[(c-0x2000)>>5]];
146-
return static_cast<UBool>((bits >> (c & 0x1f)) & 1);
146+
return (bits >> (c & 0x1f)) & 1;
147147
} else if(0xfd3e<=c && c<=0xfe46) {
148148
return c<=0xfd3f || 0xfe45<=c;
149149
} else {
@@ -156,7 +156,7 @@ PatternProps::isWhiteSpace(UChar32 c) {
156156
if(c<0) {
157157
return false;
158158
} else if(c<=0xff) {
159-
return static_cast<UBool>(latin1[c] >> 2) & 1;
159+
return (latin1[c] >> 2) & 1;
160160
} else if(0x200e<=c && c<=0x2029) {
161161
return c<=0x200f || 0x2028<=c;
162162
} else {

icu4c/source/common/putil.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ uprv_isNaN(double number)
342342
BitPatternConversion convertedNumber;
343343
convertedNumber.d64 = number;
344344
/* Infinity is 0x7FF0000000000000U. Anything greater than that is a NaN */
345-
return (UBool)((convertedNumber.i64 & U_INT64_MAX) > gInf.i64);
345+
return (convertedNumber.i64 & U_INT64_MAX) > gInf.i64;
346346

347347
#elif U_PLATFORM == U_PF_OS390
348348
uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
@@ -368,7 +368,7 @@ uprv_isInfinite(double number)
368368
BitPatternConversion convertedNumber;
369369
convertedNumber.d64 = number;
370370
/* Infinity is exactly 0x7FF0000000000000U. */
371-
return (UBool)((convertedNumber.i64 & U_INT64_MAX) == gInf.i64);
371+
return (convertedNumber.i64 & U_INT64_MAX) == gInf.i64;
372372
#elif U_PLATFORM == U_PF_OS390
373373
uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
374374
sizeof(uint32_t));
@@ -389,7 +389,7 @@ U_CAPI UBool U_EXPORT2
389389
uprv_isPositiveInfinity(double number)
390390
{
391391
#if IEEE_754 || U_PLATFORM == U_PF_OS390
392-
return (UBool)(number > 0 && uprv_isInfinite(number));
392+
return number > 0 && uprv_isInfinite(number);
393393
#else
394394
return uprv_isInfinite(number);
395395
#endif
@@ -399,7 +399,7 @@ U_CAPI UBool U_EXPORT2
399399
uprv_isNegativeInfinity(double number)
400400
{
401401
#if IEEE_754 || U_PLATFORM == U_PF_OS390
402-
return (UBool)(number < 0 && uprv_isInfinite(number));
402+
return number < 0 && uprv_isInfinite(number);
403403

404404
#else
405405
uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
@@ -744,11 +744,11 @@ static UBool isValidOlsonID(const char *id) {
744744
The timezone is sometimes set to "CST-7CDT", "CST6CDT5,J129,J131/19:30",
745745
"GRNLNDST3GRNLNDDT" or similar, so we cannot use it.
746746
The rest of the time it could be an Olson ID. George */
747-
return static_cast<UBool>(id[idx] == 0
747+
return id[idx] == 0
748748
|| uprv_strcmp(id, "PST8PDT") == 0
749749
|| uprv_strcmp(id, "MST7MDT") == 0
750750
|| uprv_strcmp(id, "CST6CDT") == 0
751-
|| uprv_strcmp(id, "EST5EDT") == 0);
751+
|| uprv_strcmp(id, "EST5EDT") == 0;
752752
}
753753

754754
/* On some Unix-like OS, 'posix' subdirectory in

icu4c/source/common/ubidi_props.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ubidi_getClass(UChar32 c) {
139139
U_CFUNC UBool
140140
ubidi_isMirrored(UChar32 c) {
141141
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
142-
return (UBool)UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT);
142+
return UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT);
143143
}
144144

145145
static UChar32
@@ -183,13 +183,13 @@ ubidi_getMirror(UChar32 c) {
183183
U_CFUNC UBool
184184
ubidi_isBidiControl(UChar32 c) {
185185
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
186-
return (UBool)UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT);
186+
return UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT);
187187
}
188188

189189
U_CFUNC UBool
190190
ubidi_isJoinControl(UChar32 c) {
191191
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
192-
return (UBool)UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT);
192+
return UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT);
193193
}
194194

195195
U_CFUNC UJoiningType

icu4c/source/common/ucase.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,17 +696,17 @@ getDotType(UChar32 c) {
696696

697697
U_CAPI UBool U_EXPORT2
698698
ucase_isSoftDotted(UChar32 c) {
699-
return (UBool)(getDotType(c)==UCASE_SOFT_DOTTED);
699+
return getDotType(c)==UCASE_SOFT_DOTTED;
700700
}
701701

702702
U_CAPI UBool U_EXPORT2
703703
ucase_isCaseSensitive(UChar32 c) {
704704
uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c);
705705
if(!UCASE_HAS_EXCEPTION(props)) {
706-
return (UBool)((props&UCASE_SENSITIVE)!=0);
706+
return (props&UCASE_SENSITIVE)!=0;
707707
} else {
708708
const uint16_t *pe=GET_EXCEPTIONS(&ucase_props_singleton, props);
709-
return (UBool)((*pe&UCASE_EXC_SENSITIVE)!=0);
709+
return (*pe&UCASE_EXC_SENSITIVE)!=0;
710710
}
711711
}
712712

@@ -1623,12 +1623,12 @@ ucase_toFullFolding(UChar32 c,
16231623

16241624
U_CAPI UBool U_EXPORT2
16251625
u_isULowercase(UChar32 c) {
1626-
return (UBool)(UCASE_LOWER==ucase_getType(c));
1626+
return UCASE_LOWER==ucase_getType(c);
16271627
}
16281628

16291629
U_CAPI UBool U_EXPORT2
16301630
u_isUUppercase(UChar32 c) {
1631-
return (UBool)(UCASE_UPPER==ucase_getType(c));
1631+
return UCASE_UPPER==ucase_getType(c);
16321632
}
16331633

16341634
/* Transforms the Unicode character to its lower case equivalent.*/

0 commit comments

Comments
 (0)