mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Remove unecessary unicode collation algorithm shims
This commit is contained in:
@@ -155,76 +155,6 @@ private:
|
||||
ASCIICollation(const ASCIICollation &) = delete;
|
||||
};
|
||||
|
||||
/// Compares the strings via the Unicode Collation Algorithm on the root locale.
|
||||
/// Results are the usual string comparison results:
|
||||
/// <0 the left string is less than the right string.
|
||||
/// ==0 the strings are equal according to their collation.
|
||||
/// >0 the left string is greater than the right string.
|
||||
int32_t
|
||||
swift::_swift_stdlib_unicode_compare_utf16_utf16(const uint16_t *LeftString,
|
||||
int32_t LeftLength,
|
||||
const uint16_t *RightString,
|
||||
int32_t RightLength) {
|
||||
// ICU UChar type is platform dependent. In Cygwin, it is defined
|
||||
// as wchar_t which size is 2. It seems that the underlying binary
|
||||
// representation is same with swift utf16 representation.
|
||||
// On Clang 4.0 under a recent Linux, ICU uses the built-in char16_t type.
|
||||
return ucol_strcoll(GetRootCollator(),
|
||||
reinterpret_cast<const UChar *>(LeftString), LeftLength,
|
||||
reinterpret_cast<const UChar *>(RightString), RightLength);
|
||||
}
|
||||
|
||||
/// Compares the strings via the Unicode Collation Algorithm on the root locale.
|
||||
/// Results are the usual string comparison results:
|
||||
/// <0 the left string is less than the right string.
|
||||
/// ==0 the strings are equal according to their collation.
|
||||
/// >0 the left string is greater than the right string.
|
||||
int32_t
|
||||
swift::_swift_stdlib_unicode_compare_utf8_utf16(const unsigned char *LeftString,
|
||||
int32_t LeftLength,
|
||||
const uint16_t *RightString,
|
||||
int32_t RightLength) {
|
||||
UCharIterator LeftIterator;
|
||||
UCharIterator RightIterator;
|
||||
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||
|
||||
uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
|
||||
uiter_setString(&RightIterator, reinterpret_cast<const UChar *>(RightString),
|
||||
RightLength);
|
||||
|
||||
uint32_t Diff = ucol_strcollIter(GetRootCollator(),
|
||||
&LeftIterator, &RightIterator, &ErrorCode);
|
||||
if (U_FAILURE(ErrorCode)) {
|
||||
swift::crash("ucol_strcollIter: Unexpected error doing utf8<->utf16 string comparison.");
|
||||
}
|
||||
return Diff;
|
||||
}
|
||||
|
||||
/// Compares the strings via the Unicode Collation Algorithm on the root locale.
|
||||
/// Results are the usual string comparison results:
|
||||
/// <0 the left string is less than the right string.
|
||||
/// ==0 the strings are equal according to their collation.
|
||||
/// >0 the left string is greater than the right string.
|
||||
int32_t
|
||||
swift::_swift_stdlib_unicode_compare_utf8_utf8(const unsigned char *LeftString,
|
||||
int32_t LeftLength,
|
||||
const unsigned char *RightString,
|
||||
int32_t RightLength) {
|
||||
UCharIterator LeftIterator;
|
||||
UCharIterator RightIterator;
|
||||
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||
|
||||
uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
|
||||
uiter_setUTF8(&RightIterator, reinterpret_cast<const char *>(RightString), RightLength);
|
||||
|
||||
uint32_t Diff = ucol_strcollIter(GetRootCollator(),
|
||||
&LeftIterator, &RightIterator, &ErrorCode);
|
||||
if (U_FAILURE(ErrorCode)) {
|
||||
swift::crash("ucol_strcollIter: Unexpected error doing utf8<->utf8 string comparison.");
|
||||
}
|
||||
return Diff;
|
||||
}
|
||||
|
||||
void *swift::_swift_stdlib_unicodeCollationIterator_create(
|
||||
const __swift_uint16_t *Str, __swift_uint32_t Length) {
|
||||
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user