Drivers/SerializedDriver/cereal/external/rapidjson/reader.h
//! Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once.
Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once.
Skip whitespace with SSE2 instructions testing 16 8 - byte characters at once .
inline const char *SkipWhitespace_SIMD(const char* p) {
	static const char whitespaces[4][17] = {
		"                ",
		"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
		"\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r",
		"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"};
	__m128i w0 = _mm_loadu_si128((const __m128i *)&whitespaces[0][0]);
	__m128i w1 = _mm_loadu_si128((const __m128i *)&whitespaces[1][0]);
	__m128i w2 = _mm_loadu_si128((const __m128i *)&whitespaces[2][0]);
	__m128i w3 = _mm_loadu_si128((const __m128i *)&whitespaces[3][0]);
	for (;;) {
		__m128i s = _mm_loadu_si128((const __m128i *)p);
		__m128i x = _mm_cmpeq_epi8(s, w0);
		x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1));
		x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2));
		x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3));
		unsigned short r = ~_mm_movemask_epi8(x);
		if (r == 0)	
			p += 16;
		else {		
#ifdef _MSC_VER		
			unsigned long offset;
			if (_BitScanForward(&offset, r))
				return p + offset;
#else
			if (r != 0)
				return p + __builtin_ffs(r) - 1;
#endif
		}
	}
}
inline const char * SkipWhitespace_SIMD ( const char * p ) { static const char whitespaces [ 4 ] [ 17 ] = { " " , " \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n " , " \r \r \r \r \r \r \r \r \r \r \r \r \r \r \r \r " , " \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t " } ; __m128i w0 = _mm_loadu_si128 ( ( const __m128i * ) & whitespaces [ 0 ] [ 0 ] ) ; __m128i w1 = _mm_loadu_si128 ( ( const __m128i * ) & whitespaces [ 1 ] [ 0 ] ) ; __m128i w2 = _mm_loadu_si128 ( ( const __m128i * ) & whitespaces [ 2 ] [ 0 ] ) ; __m128i w3 = _mm_loadu_si128 ( ( const __m128i * ) & whitespaces [ 3 ] [ 0 ] ) ; for ( ; ; ) { __m128i s = _mm_loadu_si128 ( ( const __m128i * ) p ) ; __m128i x = _mm_cmpeq_epi8 ( s , w0 ) ; x = _mm_or_si128 ( x , _mm_cmpeq_epi8 ( s , w1 ) ) ; x = _mm_or_si128 ( x , _mm_cmpeq_epi8 ( s , w2 ) ) ; x = _mm_or_si128 ( x , _mm_cmpeq_epi8 ( s , w3 ) ) ; unsigned short r = ~ _mm_movemask_epi8 ( x ) ; if ( r == 0 ) p += 16 ; else { #ifdef _MSC_VER unsigned long offset ; if ( _BitScanForward ( & offset , r ) ) return p + offset ; #else if ( r != 0 ) return p + __builtin_ffs ( r ) - 1 ; #endif } } }
Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once.
Skip whitespace with SSE2 instructions testing 16 8 - byte characters at once .
// all 16 characters are whitespace // some of characters may be non-whitespace // Find the index of first non-whitespace