diff --git a/CMakeLists.txt b/CMakeLists.txt index 3412ac3..3143021 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ option(LIBUNICODE_EXAMPLES "libunicode: Enables building of example programs. [d option(LIBUNICODE_TESTING "libunicode: Enables building of unittests for libunicode [default: ${MASTER_PROJECT}" ${MASTER_PROJECT}) option(LIBUNICODE_TOOLS "libunicode: Builds CLI tools [default: ${MASTER_PROJECT}]" ${MASTER_PROJECT}) option(LIBUNICODE_BUILD_STATIC "libunicode: provide static library instead of dynamic [default: ${LIBUNICODE_BUILD_STATIC_DEFAULT}]" ${LIBUNICODE_BUILD_STATIC_DEFAULT}) +option(LIBUNICODE_USE_INTRINSICS "libunicode: Use SIMD extenstion during text read [default: ON]" ON) include(ThirdParties) diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index fd745da..8571fd1 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -235,7 +235,7 @@ main() Darwin) install_deps_darwin ;; - freebsd) + FreeBSD) install_deps_FreeBSD ;; *) diff --git a/src/libunicode/CMakeLists.txt b/src/libunicode/CMakeLists.txt index 6c5ac20..a9329e4 100644 --- a/src/libunicode/CMakeLists.txt +++ b/src/libunicode/CMakeLists.txt @@ -110,6 +110,10 @@ add_library(unicode ${LIBUNICODE_LIB_MODE} codepoint_properties_names.cpp ) +if(LIBUNICODE_USE_INTRINSICS) + target_compile_definitions(unicode PRIVATE USE_INTRINSICS) +endif() + set(public_headers capi.h codepoint_properties.h diff --git a/src/libunicode/scan.cpp b/src/libunicode/scan.cpp index 5cfaaef..e6c203e 100644 --- a/src/libunicode/scan.cpp +++ b/src/libunicode/scan.cpp @@ -81,6 +81,7 @@ size_t detail::scan_for_text_ascii(string_view text, size_t maxColumnCount) noex auto input = text.data(); auto const end = text.data() + min(text.size(), maxColumnCount); +#if defined(USE_INTRINSICS) intrinsics::m128i const ControlCodeMax = intrinsics::set1_epi8(0x20); // 0..0x1F intrinsics::m128i const Complex = intrinsics::set1_epi8(-128); // equals to 0x80 (0b1000'0000) @@ -99,6 +100,7 @@ size_t detail::scan_for_text_ascii(string_view text, size_t maxColumnCount) noex } input += sizeof(intrinsics::m128i); } +#endif while (input != end && is_ascii(*input)) ++input;