Skip to content

Gecode 7: pass large parameters by const reference - #288

Draft
zayenz wants to merge 6 commits into
feature/breaking-7-04-empty-arraysfrom
feature/breaking-7-05-value-params
Draft

zayenz wants to merge 6 commits into
feature/breaking-7-04-empty-arraysfrom
feature/breaking-7-05-value-params

Conversation

@zayenz

@zayenz zayenz commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Several Gecode APIs took owned handles, argument arrays, callbacks, and FloatVal by value even when they only read them, paying for reference-count updates or allocations on every call. This PR enables performance-unnecessary-value-param and updates the codebase to match.

The parameter rule added to docs/code-style.md splits types into two groups:

  • Shallow handles stay passed by value (listed in the check's AllowedTypes): Home, groups, Pos, Reify, variables (IntVar, etc.), variable arrays, ViewArray, open lists, and views. Copying one copies a few pointers or ids with no allocation or reference count.
  • Reference-counted and owning types (SharedHandle subclasses such as IntSet, TupleSet, DFA, Rnd, Action, and CHB, SharedArray, *Args, REG, strings, and callbacks) along with FloatVal (two doubles, not a handle) are now taken by const& when only read, or taken by value and moved with std::move when stored.

Most of the diff is mechanical, split into commits by area to keep review manageable:

  • Branch configuration handles, moving brancher filter and print callbacks into SharedData storage so they are moved rather than copied.
  • CBS hooks, shared posting data, execution callbacks, open lists, and tracing.
  • FlatZinc, Gist, search, tests, and examples.
  • FloatVal, in its own commit.

The last commit enables performance-unnecessary-value-param in .clang-tidy and documents the rule in docs/code-style.md.

Stack

Merge in this order. #242 targets main, and each later PR builds on the one before it so its diff shows only its own commits. The first four PRs are standalone search and random-number changes; #284 through #274 are the Gecode 7 changes split out of what used to be a single branch.

  1. Rank solutions with Space::compare in best-solution search #242 Rank solutions with Space::compare
  2. Rename the meta-search hooks to hub and spoke #282 Rename the meta-search hooks to hub and spoke
  3. Give meta search hub and spoke contexts and report why search ended #283 Hub and spoke contexts and end reasons
  4. Add extensible random generators with reproducible stream splitting #241 Splittable random generators
  5. Gecode 7: CMake-only C++23 build baseline #284 Gecode 7: build baseline
  6. Gecode 7: format the sources with LLVM 22 #285 Gecode 7: reformat
  7. Gecode 7: normalized API names, LT constants and Clang checks #286 Gecode 7: API names, LT constants, checks
  8. Gecode 7: post nothing for empty arrays #287 Gecode 7: empty arrays
  9. Gecode 7: pass large parameters by const reference #288 Gecode 7: const& parameters ← this PR
  10. Gecode 7: state and assert the heap size contract #289 Gecode 7: heap contract
  11. Gecode 7: trivially copyable handles and defaulted special members #290 Gecode 7: modern classes
  12. Gecode 7: native float interval instead of Boost #291 Gecode 7: native float interval
  13. Gecode 7: bug fixes and Doxygen warnings #292 Gecode 7: bug fixes and Doxygen
  14. Gecode 7: scoped enums and descriptive constant names #293 Gecode 7: scoped enums
  15. Gecode 7: clang-tidy sweep #274 Gecode 7: clang-tidy sweep

Zdev-Change-Id: Zcab7b04117e00a1fae0ceb57e7f08b8ef521927647e15241606b165f7a4eb00e
Zdev-Change-Id: Z757c255838d9ab5582918cb98071b2660dbb370a68149ff589c16d34f4410986
…and tracing

Zdev-Change-Id: Zf998dffd1006fff50b23b42adcc1fc221887df0830b7a06397c01341484cce7d
Zdev-Change-Id: Za9107647ee8a830efc792dd21dd7b38a4435f208b81cc6f685607cf606421094
Zdev-Change-Id: Z9c9aa854f95a78c2fbb7e6930e3b50733187129e78720bdcdb1a830d578321ad
… rule

Zdev-Change-Id: Z866642b8abb6de44b9e3b3ba31eea59a5ee562ec86fa93292ba9ce73ab1d698a

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant