- Add updated versions of UVector::addElement() and ensureCapacity() that respect
incoming errors.
Follow on to c26aebe, which renamed the original versions.
- Add UVector::adoptElement() as a replacement for addElement() when the vector
has a deleter function set, meaning that it adopts ownership of its elements.
The intent is to make the behavior clearer at the call sites when looking
at unfamiliar code.
- Make all functions with an incoming failure, as indicated by a UErrorCode parameter,
leave the vector unchanged.
- Change all functions that store object pointers into the vector such that,
when the store cannot be completed for any reason _and_ the vector has a deleter function,
then the incoming object is deleted.
This change can simplify the error handling code around calls to the affected functions
(addElement() and insertElementAt(), in particular)
- Add index bounds checking on functions where it was possible - that is, on functions
with both U_ErrorCode and index parameters.
- Changed to more modern C++ idioms in some parts of the UVector implementation.
- Review & update as required all uses of the UVector functions
setElementAt(), insertElementAt(), setSize(), sortedInsert()
these being the functions with changed behavior on error conditions
(aside from addElement()).
This PR will be followed by more, switching call sites in various ICU services
from UVector::addElementX() (old behavior on errors)
to UVector::addElement() (new behavior on errors)
- replace UResourceBundle.fResData with access via fData
- change ResourceDataValue.resData into a pointer
- move C tests to C++ that stack-allocate now-C++ UResourceBundle
- init_resb_result():
- remove redundant ResourceData parameter
- simplify memory management, and various small simplifications
- /LOCALE/path reuse valid locale, no ures_open()
- pull alias-fetching code into separate function getAliasTargetAsResourceBundle()
- `const char *` for keyPath pieces
- s/noAlias/recursionDepth/
- getAllItemsWithFallback() set correct parentBundle.fValidLocaleDataEntry
Changes:
- We can completely remove the shift tables and related fields from
data structs.
- Creation of UStringSearch objects should be faster now,
as it doesn't waste time computing the unused shift tables.
- The sizeof(UStringSearch) is decreased from 5240 to 3192, so
this should help to reduce memory for applications that create many string search objects.
Note regarding the comments on initialize(). It actually does not set illegal argument error if pattern is all ignoreables. Added a test case for it.
Now when all equality operators return standard bool (commit 633438f),
it no longer makes any sense to use the ICU4C constants TRUE & FALSE
or local variables of type UBool for their return value.
The existing polymorphic equality operators that use different types for
the `this` and `other` objects are ambiguous with C++20 resolution rules
that require equality for reversed arguments.
In order to resolve that, while also possibly making the implementation
somewhat simpler overall, the implementation classes (LocaleCacheKey
and DateFmtBestPatternKey) now get normal (non-polymorphic) equality
operators that are trivially non-ambiguous (and as a bonus also don't
need any type casts), while the dynamic type checking logic is moved
into protected helper functions, which in the end are invoked
(without any ambiguity) by friend operators in the base class.
This way, all equality testing of cache key objects ends up taking one
of these two possible paths:
1. Both sides of the equality operator are of the same implementation
type (ie. LocaleCacheKey or DateFmtBestPatternKey):
The type specific equality operator is called directly, comparing the
relevant attributes of the two objects directly.
2. The two sides of the equality operator are either of different types
or of some base class type:
The friend equality operators of CacheKeyBase call the virtual helper
function to figure out whether the two objects are actually of the
same type and if they are and this type is an implementation type
then does the necessary type cast to get to 1.
An operator!=() is already defined by a base class so this class doesn't
need to define it again and not doing so avoids a C++20 ambiguity.
This simplifies the code.
Add test case for LocaleBuilder with default locale with extensions.
Use Locale::getRoot().clone() instead of new Locale();
Add CI build bot with LANG that has extension tags