ICU-4092 Increase code coverage by merging redundant lines

X-SVN-Rev: 17011
This commit is contained in:
George Rhoten 2004-12-23 19:21:10 +00:00
parent 25b8fed2bb
commit 6c0562fc29
2 changed files with 12 additions and 39 deletions

View File

@ -42,30 +42,12 @@ ResourceBundle::constructForLocale(const UnicodeString& path,
const Locale& locale,
UErrorCode& error)
{
char name[300];
if(path.length() >= (int32_t)sizeof(name)) {
fResource = NULL;
error = U_ILLEGAL_ARGUMENT_ERROR;
} else if(!path.isEmpty()) {
if(uprv_isInvariantUString(path.getBuffer(), path.length())) {
// the invariant converter is sufficient for package and tree names
// and is more efficient
path.extract(0, INT32_MAX, name, (int32_t)sizeof(name), US_INV);
} else {
#if !UCONFIG_NO_CONVERSION
// use the default converter to support variant-character paths
path.extract(name, sizeof(name), 0, error);
#else
// the default converter is not available
fResource = NULL;
error = U_UNSUPPORTED_ERROR;
return;
#endif
}
fResource = ures_open(name, locale.getName(), &error);
} else {
fResource = ures_open(0, locale.getName(), &error);
if (path.isEmpty()) {
fResource = ures_open(NULL, locale.getName(), &error);
}
else {
UnicodeString nullTerminatedPath(path);
fResource = ures_openU(nullTerminatedPath.getTerminatedBuffer(), locale.getName(), &error);
}
}

View File

@ -103,7 +103,7 @@ offsetTOCLookupFn(const UDataMemory *pData,
UErrorCode *pErrorCode) {
const UDataOffsetTOC *toc = (UDataOffsetTOC *)pData->toc;
if(toc!=NULL) {
const char *base=(const char *)pData->toc;
const char *base=(const char *)toc;
uint32_t start, limit, number, lastNumber;
int32_t strResult;
const UDataOffsetTOCEntry *entry;
@ -120,13 +120,11 @@ offsetTOCLookupFn(const UDataMemory *pData,
limit=toc->count; /* number of names in this table of contents */
lastNumber=limit;
entry=toc->entry;
if (limit == 0) { /* Stub common data library used during build is empty. */
return NULL;
}
for (;;) {
number = (start+limit)/2;
if (lastNumber == number) { /* Have we moved? */
break; /* We haven't moved, and it wasn't found. */
break; /* We haven't moved, and it wasn't found; */
/* or the empty stub common data library was used during build. */
}
lastNumber = number;
strResult = uprv_strcmp(tocEntryName, base+entry[number].nameOffset);
@ -165,11 +163,7 @@ offsetTOCLookupFn(const UDataMemory *pData,
static uint32_t pointerTOCEntryCount(const UDataMemory *pData) {
const PointerTOC *toc = (PointerTOC *)pData->toc;
if (toc != NULL) {
return toc->count;
} else {
return 0;
}
return (uint32_t)((toc != NULL) ? (toc->count) : 0);
}
@ -194,14 +188,11 @@ static const DataHeader *pointerTOCLookupFn(const UDataMemory *pData,
limit=toc->count;
lastNumber=limit;
if (limit == 0) { /* Stub common data library used during build is empty. */
return NULL;
}
for (;;) {
number = (start+limit)/2;
if (lastNumber == number) { /* Have we moved? */
break; /* We haven't moved, and it wasn't found. */
break; /* We haven't moved, and it wasn't found, */
/* or the empty stub common data library was used during build. */
}
lastNumber = number;
strResult = uprv_strcmp(name, toc->entry[number].entryName);