From 5bc9f0e942973a4a35c35c5e710fbbbbd73b95e0 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 24 Apr 2022 15:09:32 +0200 Subject: [PATCH 1/6] static const -> static constexpr --- include/gfx/timsort.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/gfx/timsort.hpp b/include/gfx/timsort.hpp index b92b594..2b329cf 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 From 7ca1a657c57b82bedfa12588ae1a465d033bcb5c Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 24 Apr 2022 15:28:30 +0200 Subject: [PATCH 2/6] CI: move Windows builds to windows-2019 image --- .../{build-windows.yml => build-mingw.yml} | 13 +++-- .github/workflows/build-msvc.yml | 52 +++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) rename .github/workflows/{build-windows.yml => build-mingw.yml} (79%) create mode 100644 .github/workflows/build-msvc.yml diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-mingw.yml similarity index 79% rename from .github/workflows/build-windows.yml rename to .github/workflows/build-mingw.yml index c7ce066..0263882 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 diff --git a/.github/workflows/build-msvc.yml b/.github/workflows/build-msvc.yml new file mode 100644 index 0000000..5fe3c67 --- /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}} From 5c9dabf92f0aed2bcc597f64ecfd9a9e3fd215a1 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 24 Apr 2022 17:01:31 +0200 Subject: [PATCH 3/6] CI: fail when no tests are run --- .github/workflows/build-macos.yml | 2 +- .github/workflows/build-mingw.yml | 2 +- .github/workflows/build-msvc.yml | 2 +- .github/workflows/build-ubuntu.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) 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-mingw.yml b/.github/workflows/build-mingw.yml index 0263882..bf3d994 100644 --- a/.github/workflows/build-mingw.yml +++ b/.github/workflows/build-mingw.yml @@ -49,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 index 5fe3c67..a9142d6 100644 --- a/.github/workflows/build-msvc.yml +++ b/.github/workflows/build-msvc.yml @@ -49,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-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; From 12cfa60e6ae5fa402a0617bacafda2f5d9071b49 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 24 Apr 2022 17:57:25 +0200 Subject: [PATCH 4/6] push_back -> emplace_back --- include/gfx/timsort.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gfx/timsort.hpp b/include/gfx/timsort.hpp index 2b329cf..2c7f8bd 100644 --- a/include/gfx/timsort.hpp +++ b/include/gfx/timsort.hpp @@ -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) { From 99b612d9826e8387a30008f2b21be206181ad890 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 24 Apr 2022 18:38:43 +0200 Subject: [PATCH 5/6] Use single-parameter std::next/std::prev when possible Some standard library implementations have special cases and call operators ++/-- instead of +=/-= when possible, which can lead to slightly better codegen for non-trivial random-access iterator types such as those of std::deque. --- include/gfx/timsort.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/gfx/timsort.hpp b/include/gfx/timsort.hpp index 2c7f8bd..f220410 100644 --- a/include/gfx/timsort.hpp +++ b/include/gfx/timsort.hpp @@ -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; @@ -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; } From 3f1bb8cd31061cae35a239e7d9ab9d27ad60ffa4 Mon Sep 17 00:00:00 2001 From: "mend-for-github-com[bot]" <50673670+mend-for-github-com[bot]@users.noreply.github.com> Date: Sun, 4 Dec 2022 13:27:10 +0000 Subject: [PATCH 6/6] Add .whitesource configuration file --- .whitesource | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .whitesource 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