Browse Source

LibRegex: Avoid pointlessly slicing a UTF-16 string for one code unit

This simple change is a nice 9% speedup on the regex test suite :^)
Ali Mohammad Pur 2 năm trước cách đây
mục cha
commit
fbab9bc330
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      Userland/Libraries/LibRegex/RegexByteCode.cpp

+ 1 - 1
Userland/Libraries/LibRegex/RegexByteCode.cpp

@@ -559,7 +559,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
             auto range_data = m_bytecode->template spans<4>().slice(offset, count);
             offset += count;
 
-            auto ch = input.view.substring_view(state.string_position, 1)[0];
+            auto ch = input.view[state.string_position_in_code_units];
 
             auto const* matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
                 auto upper_case_needle = needle;