diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 422bced..0e92ae1 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -62,4 +62,4 @@ jobs: env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.config.build_type}} + run: ctest -C ${{matrix.config.build_type}} --no-tests=error diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-mingw.yml similarity index 75% rename from .github/workflows/build-windows.yml rename to .github/workflows/build-mingw.yml index c7ce066..bf3d994 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-mingw.yml @@ -1,19 +1,19 @@ -# Copyright (c) 2021 Morwenn +# Copyright (c) 2021-2022 Morwenn # SPDX-License-Identifier: MIT -name: Windows Builds +name: MinGW-w64 Builds on: push: paths: - - '.github/workflows/build-windows.yml' + - '.github/workflows/build-mingw.yml' - 'CMakeLists.txt' - 'cmake/**' - 'include/gfx/timsort.hpp' - 'tests/*' pull_request: paths: - - '.github/workflows/build-windows.yml' + - '.github/workflows/build-mingw.yml' - 'CMakeLists.txt' - 'cmake/**' - 'include/gfx/timsort.hpp' @@ -21,13 +21,12 @@ on: jobs: build: - runs-on: windows-2016 + runs-on: windows-2019 strategy: fail-fast: false matrix: build_type: [Debug, Release] - cmake_generator: ['MinGW Makefiles', 'Visual Studio 15 2017 Win64'] steps: - uses: actions/checkout@v2 @@ -39,7 +38,7 @@ jobs: cmake -H${{github.event.repository.name}} -Bbuild ` -DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} ` -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` - -G"${{matrix.cmake_generator}}" ` + -G"MinGW Makefiles" ` -DBUILD_BENCHMARKS=ON - name: Build the test suite @@ -50,4 +49,4 @@ jobs: env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.build_type}} + run: ctest -C ${{matrix.build_type}} --no-tests=error diff --git a/.github/workflows/build-msvc.yml b/.github/workflows/build-msvc.yml new file mode 100644 index 0000000..a9142d6 --- /dev/null +++ b/.github/workflows/build-msvc.yml @@ -0,0 +1,52 @@ +# Copyright (c) 2021-2022 Morwenn +# SPDX-License-Identifier: MIT + +name: MSVC Builds + +on: + push: + paths: + - '.github/workflows/build-msvc.yml' + - 'CMakeLists.txt' + - 'cmake/**' + - 'include/gfx/timsort.hpp' + - 'tests/*' + pull_request: + paths: + - '.github/workflows/build-msvc.yml' + - 'CMakeLists.txt' + - 'cmake/**' + - 'include/gfx/timsort.hpp' + - 'tests/*' + +jobs: + build: + runs-on: windows-2019 + + strategy: + fail-fast: false + matrix: + build_type: [Debug, Release] + + steps: + - uses: actions/checkout@v2 + + - name: Configure CMake + shell: pwsh + working-directory: ${{runner.workspace}} + run: | + cmake -H${{github.event.repository.name}} -Bbuild ` + -DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} ` + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` + -G"Visual Studio 16 2019" -A x64 ` + -DBUILD_BENCHMARKS=ON + + - name: Build the test suite + working-directory: ${{runner.workspace}}/build + run: cmake --build . --config ${{matrix.build_type}} -j 2 + + - name: Run the test suite + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} --no-tests=error diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 31f99a2..0452d21 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -78,7 +78,7 @@ jobs: env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.config.build_type}} + run: ctest -C ${{matrix.config.build_type}} --no-tests=error - name: Run the test suite with Memcheck if: ${{matrix.config.valgrind == 'ON'}} @@ -86,5 +86,5 @@ jobs: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build run: | - ctest -T memcheck -C ${{matrix.config.build_type}} -j 2 + ctest -T memcheck -C ${{matrix.config.build_type}} --no-tests=error -j 2 find ./Testing/Temporary -name "MemoryChecker.*.log" -size +1300c | xargs cat; diff --git a/.whitesource b/.whitesource new file mode 100644 index 0000000..c94b2a0 --- /dev/null +++ b/.whitesource @@ -0,0 +1,3 @@ +{ + "settingsInheritedFrom": "cleohari/whitesource-config@main" +} \ No newline at end of file diff --git a/include/gfx/timsort.hpp b/include/gfx/timsort.hpp index b92b594..f220410 100644 --- a/include/gfx/timsort.hpp +++ b/include/gfx/timsort.hpp @@ -6,7 +6,7 @@ * - http://cr.openjdk.java.net/~martin/webrevs/openjdk7/timsort/raw_files/new/src/share/classes/java/util/TimSort.java * * Copyright (c) 2011 Fuji, Goro (gfx) . - * Copyright (c) 2019-2021 Morwenn. + * Copyright (c) 2019-2022 Morwenn. * Copyright (c) 2021 Igor Kushnir . * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -127,8 +127,8 @@ template class TimSort { typedef typename std::iterator_traits::reference ref_t; typedef typename std::iterator_traits::difference_type diff_t; - static const int MIN_MERGE = 32; - static const int MIN_GALLOP = 7; + static constexpr int MIN_MERGE = 32; + static constexpr int MIN_GALLOP = 7; int minGallop_; // default to MIN_GALLOP @@ -149,7 +149,7 @@ template class TimSort { iter_t const pos = std::upper_bound(lo, start, pivot, compare); for (iter_t p = start; p > pos; --p) { - *p = std::move(*(p - 1)); + *p = std::move(*std::prev(p)); } *pos = std::move(pivot); } @@ -158,7 +158,7 @@ template class TimSort { static diff_t countRunAndMakeAscending(iter_t const lo, iter_t const hi, Compare compare) { GFX_TIMSORT_ASSERT(lo < hi); - iter_t runHi = lo + 1; + auto runHi = std::next(lo); if (runHi == hi) { return 1; } @@ -166,12 +166,12 @@ template class TimSort { if (compare(*runHi, *lo)) { // decreasing do { ++runHi; - } while (runHi < hi && compare(*runHi, *(runHi - 1))); + } while (runHi < hi && compare(*runHi, *std::prev(runHi))); std::reverse(lo, runHi); } else { // non-decreasing do { ++runHi; - } while (runHi < hi && !compare(*runHi, *(runHi - 1))); + } while (runHi < hi && !compare(*runHi, *std::prev(runHi))); } return runHi - lo; @@ -195,7 +195,7 @@ template class TimSort { ~TimSort() {} void pushRun(iter_t const runBase, diff_t const runLen) { - pending_.push_back(run(runBase, runLen)); + pending_.emplace_back(runBase, runLen); } void mergeCollapse(Compare compare) { @@ -382,13 +382,13 @@ template class TimSort { static void rotateLeft(iter_t first, iter_t last) { value_t tmp = std::move(*first); - iter_t last_1 = std::move(first + 1, last, first); + auto last_1 = std::move(std::next(first), last, first); *last_1 = std::move(tmp); } static void rotateRight(iter_t first, iter_t last) { - iter_t last_1 = last - 1; + auto last_1 = std::prev(last); value_t tmp = std::move(*last_1); std::move_backward(first, last_1, last); *first = std::move(tmp); @@ -598,12 +598,12 @@ template class TimSort { goto epilogue; } - count2 = len2 - gallopLeft(*(cursor1 - 1), tmp_.begin(), len2, len2 - 1, compare); + count2 = len2 - gallopLeft(*std::prev(cursor1), tmp_.begin(), len2, len2 - 1, compare); if (count2 != 0) { dest -= count2; cursor2 -= count2; len2 -= count2; - std::move(cursor2 + 1, cursor2 + (1 + count2), dest + 1); + std::move(std::next(cursor2), cursor2 + (1 + count2), std::next(dest)); if (len2 <= 1) { goto epilogue; }