|
22 | 22 | #ifndef PG_WCHAR_H
|
23 | 23 | #define PG_WCHAR_H
|
24 | 24 |
|
25 |
| -#include "port/simd.h" |
26 |
| - |
27 | 25 | /*
|
28 | 26 | * The pg_wchar type
|
29 | 27 | */
|
@@ -722,71 +720,4 @@ extern int mic2latin_with_table(const unsigned char *mic, unsigned char *p,
|
722 | 720 | extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len);
|
723 | 721 | #endif
|
724 | 722 |
|
725 |
| - |
726 |
| -/* |
727 |
| - * Verify a chunk of bytes for valid ASCII. |
728 |
| - * |
729 |
| - * Returns false if the input contains any zero bytes or bytes with the |
730 |
| - * high-bit set. Input len must be a multiple of the chunk size (8 or 16). |
731 |
| - */ |
732 |
| -static inline bool |
733 |
| -is_valid_ascii(const unsigned char *s, int len) |
734 |
| -{ |
735 |
| - const unsigned char *const s_end = s + len; |
736 |
| - Vector8 chunk; |
737 |
| - Vector8 highbit_cum = vector8_broadcast(0); |
738 |
| -#ifdef USE_NO_SIMD |
739 |
| - Vector8 zero_cum = vector8_broadcast(0x80); |
740 |
| -#endif |
741 |
| - |
742 |
| - Assert(len % sizeof(chunk) == 0); |
743 |
| - |
744 |
| - while (s < s_end) |
745 |
| - { |
746 |
| - vector8_load(&chunk, s); |
747 |
| - |
748 |
| - /* Capture any zero bytes in this chunk. */ |
749 |
| -#ifdef USE_NO_SIMD |
750 |
| - |
751 |
| - /* |
752 |
| - * First, add 0x7f to each byte. This sets the high bit in each byte, |
753 |
| - * unless it was a zero. If any resulting high bits are zero, the |
754 |
| - * corresponding high bits in the zero accumulator will be cleared. |
755 |
| - * |
756 |
| - * If none of the bytes in the chunk had the high bit set, the max |
757 |
| - * value each byte can have after the addition is 0x7f + 0x7f = 0xfe, |
758 |
| - * and we don't need to worry about carrying over to the next byte. If |
759 |
| - * any input bytes did have the high bit set, it doesn't matter |
760 |
| - * because we check for those separately. |
761 |
| - */ |
762 |
| - zero_cum &= (chunk + vector8_broadcast(0x7F)); |
763 |
| -#else |
764 |
| - |
765 |
| - /* |
766 |
| - * Set all bits in each lane of the highbit accumulator where input |
767 |
| - * bytes are zero. |
768 |
| - */ |
769 |
| - highbit_cum = vector8_or(highbit_cum, |
770 |
| - vector8_eq(chunk, vector8_broadcast(0))); |
771 |
| -#endif |
772 |
| - |
773 |
| - /* Capture all set bits in this chunk. */ |
774 |
| - highbit_cum = vector8_or(highbit_cum, chunk); |
775 |
| - |
776 |
| - s += sizeof(chunk); |
777 |
| - } |
778 |
| - |
779 |
| - /* Check if any high bits in the high bit accumulator got set. */ |
780 |
| - if (vector8_is_highbit_set(highbit_cum)) |
781 |
| - return false; |
782 |
| - |
783 |
| -#ifdef USE_NO_SIMD |
784 |
| - /* Check if any high bits in the zero accumulator got cleared. */ |
785 |
| - if (zero_cum != vector8_broadcast(0x80)) |
786 |
| - return false; |
787 |
| -#endif |
788 |
| - |
789 |
| - return true; |
790 |
| -} |
791 |
| - |
792 | 723 | #endif /* PG_WCHAR_H */
|
0 commit comments