mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove unecessary unicode collation algorithm shims
This commit is contained in:
@@ -62,27 +62,6 @@ SWIFT_RUNTIME_STDLIB_INTERFACE
|
|||||||
const __swift_uint16_t *
|
const __swift_uint16_t *
|
||||||
_swift_stdlib_ExtendedGraphemeClusterNoBoundaryRulesMatrix;
|
_swift_stdlib_ExtendedGraphemeClusterNoBoundaryRulesMatrix;
|
||||||
|
|
||||||
SWIFT_RUNTIME_STDLIB_INTERFACE
|
|
||||||
SWIFT_READONLY __swift_int32_t
|
|
||||||
_swift_stdlib_unicode_compare_utf16_utf16(const __swift_uint16_t *Left,
|
|
||||||
__swift_int32_t LeftLength,
|
|
||||||
const __swift_uint16_t *Right,
|
|
||||||
__swift_int32_t RightLength);
|
|
||||||
|
|
||||||
SWIFT_RUNTIME_STDLIB_INTERFACE
|
|
||||||
SWIFT_READONLY __swift_int32_t
|
|
||||||
_swift_stdlib_unicode_compare_utf8_utf16(const unsigned char *Left,
|
|
||||||
__swift_int32_t LeftLength,
|
|
||||||
const __swift_uint16_t *Right,
|
|
||||||
__swift_int32_t RightLength);
|
|
||||||
|
|
||||||
SWIFT_RUNTIME_STDLIB_INTERFACE
|
|
||||||
SWIFT_READONLY __swift_int32_t
|
|
||||||
_swift_stdlib_unicode_compare_utf8_utf8(const unsigned char *Left,
|
|
||||||
__swift_int32_t LeftLength,
|
|
||||||
const unsigned char *Right,
|
|
||||||
__swift_int32_t RightLength);
|
|
||||||
|
|
||||||
SWIFT_RUNTIME_STDLIB_INTERFACE
|
SWIFT_RUNTIME_STDLIB_INTERFACE
|
||||||
void *_swift_stdlib_unicodeCollationIterator_create(
|
void *_swift_stdlib_unicodeCollationIterator_create(
|
||||||
const __swift_uint16_t *Str,
|
const __swift_uint16_t *Str,
|
||||||
|
|||||||
@@ -155,76 +155,6 @@ private:
|
|||||||
ASCIICollation(const ASCIICollation &) = delete;
|
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(
|
void *swift::_swift_stdlib_unicodeCollationIterator_create(
|
||||||
const __swift_uint16_t *Str, __swift_uint32_t Length) {
|
const __swift_uint16_t *Str, __swift_uint32_t Length) {
|
||||||
UErrorCode ErrorCode = U_ZERO_ERROR;
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user