github.com/bytedance/sonic@v1.11.7-0.20240517092252-d2edb31b167b/native/validate_utf8_fast.c (about)

     1  #include "scanning.h"
     2  
     3  // validate_utf8_fast returns zero if valid, otherwise, the error position.
     4  long validate_utf8_fast(const GoString *s) {
     5  #if USE_AVX2
     6      /* fast path for valid utf8 */
     7      if (validate_utf8_avx2(s) == 0) {
     8          return 0;
     9      }
    10  #endif
    11      return validate_utf8_errors(s);
    12  }