@@ -557,9 +557,11 @@ class UTFImpl<
|
557 | 557 | public: |
558 | 558 | // Handle ill-formed UTF-8 |
559 | 559 | U_FORCE_INLINE static CP32 sub() { |
560 | | -switch (behavior) { |
561 | | -case UTF_BEHAVIOR_NEGATIVE: return U_SENTINEL; |
562 | | -case UTF_BEHAVIOR_FFFD: return 0xfffd; |
| 560 | +if constexpr (behavior == UTF_BEHAVIOR_NEGATIVE) { |
| 561 | +return U_SENTINEL; |
| 562 | + } else { |
| 563 | +static_assert(behavior == UTF_BEHAVIOR_FFFD); |
| 564 | +return 0xfffd; |
563 | 565 | } |
564 | 566 | } |
565 | 567 | |
@@ -736,10 +738,13 @@ class UTFImpl<
|
736 | 738 | public: |
737 | 739 | // Handle ill-formed UTF-16: One unpaired surrogate. |
738 | 740 | U_FORCE_INLINE static CP32 sub(CP32 surrogate) { |
739 | | -switch (behavior) { |
740 | | -case UTF_BEHAVIOR_NEGATIVE: return U_SENTINEL; |
741 | | -case UTF_BEHAVIOR_FFFD: return 0xfffd; |
742 | | -case UTF_BEHAVIOR_SURROGATE: return surrogate; |
| 741 | +if constexpr (behavior == UTF_BEHAVIOR_NEGATIVE) { |
| 742 | +return U_SENTINEL; |
| 743 | + } else if constexpr (behavior == UTF_BEHAVIOR_FFFD) { |
| 744 | +return 0xfffd; |
| 745 | + } else { |
| 746 | +static_assert(behavior == UTF_BEHAVIOR_SURROGATE); |
| 747 | +return surrogate; |
743 | 748 | } |
744 | 749 | } |
745 | 750 | |
@@ -822,10 +827,13 @@ class UTFImpl<
|
822 | 827 | public: |
823 | 828 | // Handle ill-formed UTF-32 |
824 | 829 | U_FORCE_INLINE static CP32 sub(bool forSurrogate, CP32 surrogate) { |
825 | | -switch (behavior) { |
826 | | -case UTF_BEHAVIOR_NEGATIVE: return U_SENTINEL; |
827 | | -case UTF_BEHAVIOR_FFFD: return 0xfffd; |
828 | | -case UTF_BEHAVIOR_SURROGATE: return forSurrogate ? surrogate : 0xfffd; |
| 830 | +if constexpr (behavior == UTF_BEHAVIOR_NEGATIVE) { |
| 831 | +return U_SENTINEL; |
| 832 | + } else if constexpr (behavior == UTF_BEHAVIOR_FFFD) { |
| 833 | +return 0xfffd; |
| 834 | + } else { |
| 835 | +static_assert(behavior == UTF_BEHAVIOR_SURROGATE); |
| 836 | +return forSurrogate ? surrogate : 0xfffd; |
829 | 837 | } |
830 | 838 | } |
831 | 839 | |
|