@@ -333,7 +333,7 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
333333 if (search -> matches_mask > 0 ) {
334334 return neon_next_match (search );
335335 } else {
336- // neon_next_match will only advance search->ptr up to the last matching character.
336+ // neon_next_match will only advance search->ptr up to the last matching character.
337337 // Skip over any characters in the last chunk that occur after the last match.
338338 search -> has_matches = false;
339339 search -> ptr = search -> chunk_end ;
@@ -342,40 +342,40 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
342342
343343 /*
344344 * The code below implements an SIMD-based algorithm to determine if N bytes at a time
345- * need to be escaped.
346- *
345+ * need to be escaped.
346+ *
347347 * Assume the ptr = "Te\sting!" (the double quotes are included in the string)
348- *
348+ *
349349 * The explanation will be limited to the first 8 bytes of the string for simplicity. However
350350 * the vector insructions may work on larger vectors.
351- *
351+ *
352352 * First, we load three constants 'lower_bound', 'backslash' and 'dblquote" in vector registers.
353- *
354- * lower_bound: [20 20 20 20 20 20 20 20]
355- * backslash: [5C 5C 5C 5C 5C 5C 5C 5C]
356- * dblquote: [22 22 22 22 22 22 22 22]
357- *
358- * Next we load the first chunk of the ptr:
353+ *
354+ * lower_bound: [20 20 20 20 20 20 20 20]
355+ * backslash: [5C 5C 5C 5C 5C 5C 5C 5C]
356+ * dblquote: [22 22 22 22 22 22 22 22]
357+ *
358+ * Next we load the first chunk of the ptr:
359359 * [22 54 65 5C 73 74 69 6E] (" T e \ s t i n)
360- *
360+ *
361361 * First we check if any byte in chunk is less than 32 (0x20). This returns the following vector
362362 * as no bytes are less than 32 (0x20):
363363 * [0 0 0 0 0 0 0 0]
364- *
364+ *
365365 * Next, we check if any byte in chunk is equal to a backslash:
366366 * [0 0 0 FF 0 0 0 0]
367- *
367+ *
368368 * Finally we check if any byte in chunk is equal to a double quote:
369- * [FF 0 0 0 0 0 0 0]
370- *
369+ * [FF 0 0 0 0 0 0 0]
370+ *
371371 * Now we have three vectors where each byte indicates if the corresponding byte in chunk
372372 * needs to be escaped. We combine these vectors with a series of logical OR instructions.
373373 * This is the needs_escape vector and it is equal to:
374- * [FF 0 0 FF 0 0 0 0]
375- *
374+ * [FF 0 0 FF 0 0 0 0]
375+ *
376376 * Next we compute the bitwise AND between each byte and 0x1 and compute the horizontal sum of
377377 * the values in the vector. This computes how many bytes need to be escaped within this chunk.
378- *
378+ *
379379 * Finally we compute a mask that indicates which bytes need to be escaped. If the mask is 0 then,
380380 * no bytes need to be escaped and we can continue to the next chunk. If the mask is not 0 then we
381381 * have at least one byte that needs to be escaped.
@@ -394,15 +394,15 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
394394 return neon_next_match (search );
395395 }
396396
397- // There are fewer than 16 bytes left.
397+ // There are fewer than 16 bytes left.
398398 unsigned long remaining = (search -> end - search -> ptr );
399399 if (remaining >= SIMD_MINIMUM_THRESHOLD ) {
400400 char * s = copy_remaining_bytes (search , sizeof (uint8x16_t ), remaining );
401401
402402 uint64_t mask = neon_rules_update (s );
403403
404404 if (!mask ) {
405- // Nothing to escape, ensure search_flush doesn't do anything by setting
405+ // Nothing to escape, ensure search_flush doesn't do anything by setting
406406 // search->cursor to search->ptr.
407407 fbuffer_consumed (search -> buffer , remaining );
408408 search -> ptr = search -> end ;
@@ -476,7 +476,7 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
476476 if (search -> matches_mask > 0 ) {
477477 return sse2_next_match (search );
478478 } else {
479- // sse2_next_match will only advance search->ptr up to the last matching character.
479+ // sse2_next_match will only advance search->ptr up to the last matching character.
480480 // Skip over any characters in the last chunk that occur after the last match.
481481 search -> has_matches = false;
482482 if (RB_UNLIKELY (search -> chunk_base + sizeof (__m128i ) >= search -> end )) {
@@ -501,15 +501,15 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
501501 return sse2_next_match (search );
502502 }
503503
504- // There are fewer than 16 bytes left.
504+ // There are fewer than 16 bytes left.
505505 unsigned long remaining = (search -> end - search -> ptr );
506506 if (remaining >= SIMD_MINIMUM_THRESHOLD ) {
507507 char * s = copy_remaining_bytes (search , sizeof (__m128i ), remaining );
508508
509509 int needs_escape_mask = sse2_update (s );
510510
511511 if (needs_escape_mask == 0 ) {
512- // Nothing to escape, ensure search_flush doesn't do anything by setting
512+ // Nothing to escape, ensure search_flush doesn't do anything by setting
513513 // search->cursor to search->ptr.
514514 fbuffer_consumed (search -> buffer , remaining );
515515 search -> ptr = search -> end ;
0 commit comments