File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1150,17 +1150,27 @@ namespace unicode_traits {
11501150 static constexpr uint64_t mask = 0x8080808080808080ull ;
11511151
11521152 conv_errc result{};
1153- while (it != end )
1153+ while ((end - it) >= 8 )
11541154 {
1155- if ((end - it) >= 8 ) // fast check for ascii
1155+ uint64_t chunk;
1156+ std::memcpy (&chunk, it, 8 );
1157+ if ((chunk & mask) == 0 ) {
1158+ it += 8 ;
1159+ continue ;
1160+ }
1161+ std::size_t len = static_cast <std::size_t >(trailing_bytes_for_utf8[*it]) + 1 ;
1162+ if (len > (std::size_t )(end - it))
11561163 {
1157- uint64_t chunk;
1158- std::memcpy (&chunk, it, 8 );
1159- if ((chunk & mask) == 0 ) {
1160- it += 8 ;
1161- continue ;
1162- }
1164+ return convert_result<CharT>{reinterpret_cast <const CharT*>(it), conv_errc::source_exhausted};
1165+ }
1166+ if ((result=is_legal_utf8 (it, len)) != conv_errc ())
1167+ {
1168+ return convert_result<CharT>{reinterpret_cast <const CharT*>(it),result} ;
11631169 }
1170+ it += len;
1171+ }
1172+ while (it != end)
1173+ {
11641174 std::size_t len = static_cast <std::size_t >(trailing_bytes_for_utf8[*it]) + 1 ;
11651175 if (len > (std::size_t )(end - it))
11661176 {
You can’t perform that action at this time.
0 commit comments