UnicodeWord.cpp (swift-swift-5.8-RELEASE) | : | UnicodeWord.cpp (swift-swift-5.8.1-RELEASE) | ||
---|---|---|---|---|
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | |||
// | // | |||
// This source file is part of the Swift.org open source project | // This source file is part of the Swift.org open source project | |||
// | // | |||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | // Copyright (c) 2022 - 2023 Apple Inc. and the Swift project authors | |||
// Licensed under Apache License v2.0 with Runtime Library Exception | // Licensed under Apache License v2.0 with Runtime Library Exception | |||
// | // | |||
// See https://swift.org/LICENSE.txt for license information | // See https://swift.org/LICENSE.txt for license information | |||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | |||
// | // | |||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | |||
#if SWIFT_STDLIB_ENABLE_UNICODE_DATA | #if SWIFT_STDLIB_ENABLE_UNICODE_DATA | |||
#include "Common/WordData.h" | #include "Common/WordData.h" | |||
#else | #else | |||
skipping to change at line 27 | skipping to change at line 27 | |||
#endif | #endif | |||
#include "swift/shims/UnicodeData.h" | #include "swift/shims/UnicodeData.h" | |||
#include <limits> | #include <limits> | |||
SWIFT_RUNTIME_STDLIB_INTERNAL | SWIFT_RUNTIME_STDLIB_INTERNAL | |||
__swift_uint8_t _swift_stdlib_getWordBreakProperty(__swift_uint32_t scalar) { | __swift_uint8_t _swift_stdlib_getWordBreakProperty(__swift_uint32_t scalar) { | |||
#if !SWIFT_STDLIB_ENABLE_UNICODE_DATA | #if !SWIFT_STDLIB_ENABLE_UNICODE_DATA | |||
swift::swift_abortDisabledUnicodeSupport(); | swift::swift_abortDisabledUnicodeSupport(); | |||
#else | #else | |||
auto low = 0; | auto low = 0; | |||
auto high = 1086 - 1; | auto high = WORD_BREAK_DATA_COUNT - 1; | |||
while (high >= low) { | while (high >= low) { | |||
auto idx = low + (high - low) / 2; | auto idx = low + (high - low) / 2; | |||
auto entry = _swift_stdlib_words[idx]; | auto entry = _swift_stdlib_words[idx]; | |||
// Shift the range count out of the value. | // Shift the range count out of the value. | |||
auto lower = (entry << 11) >> 11; | auto lower = (entry << 11) >> 11; | |||
// Shift the enum out first, then shift out the scalar value. | // Shift the enum out first, then shift out the scalar value. | |||
skipping to change at line 55 | skipping to change at line 55 | |||
low = idx + 1; | low = idx + 1; | |||
continue; | continue; | |||
} | } | |||
if (scalar < lower) { | if (scalar < lower) { | |||
high = idx - 1; | high = idx - 1; | |||
continue; | continue; | |||
} | } | |||
} | } | |||
// If we made it out here, then our scalar was not found in the grapheme | // If we made it out here, then our scalar was not found in the word | |||
// array (this occurs when a scalar doesn't map to any grapheme break | // array (this occurs when a scalar doesn't map to any word break | |||
// property). Return the max value here to indicate .any. | // property). Return the max value here to indicate .any. | |||
return std::numeric_limits<__swift_uint8_t>::max(); | return std::numeric_limits<__swift_uint8_t>::max(); | |||
#endif | #endif | |||
} | } | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |