Skip to content

Change HashSet copy constructor from implicit to explicit.#116381

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Ivorforce:hashset-explicit-copy
Feb 17, 2026
Merged

Change HashSet copy constructor from implicit to explicit.#116381
Repiteo merged 1 commit into
godotengine:masterfrom
Ivorforce:hashset-explicit-copy

Conversation

@Ivorforce

@Ivorforce Ivorforce commented Feb 16, 2026

Copy link
Copy Markdown
Member

This change makes it harder to accidentally copy HashSet instances. This decreases the chance of performance problems and regressions.

Programmers will be forced to take a reference, move, otherwise avoid the copy, or explicitly make the copy:

HashSet<int> hashset;

HashSet<int> other = hashset; // implicit copy, now impossible 

HashSet<int> other(hashset); // explicit copy
HashSet<int> other = HashSet<int>(hashset); // explicit copy
HashSet<int> &other = hashset; // reference
HashSet<int> other = std::move(hashset); // move

This PR is mostly performance agnostic; that is, if a copy was happening beforehand, there will be a copy afterwards (just explicit instead of implicit). There are a few minor exceptions that I'm very sure are safe.

@Ivorforce Ivorforce added this to the 4.x milestone Feb 16, 2026
@Ivorforce Ivorforce requested review from a team as code owners February 16, 2026 22:09
@Ivorforce Ivorforce requested review from a team as code owners February 16, 2026 22:09
@Ivorforce Ivorforce removed request for a team February 16, 2026 22:09
@Ivorforce Ivorforce force-pushed the hashset-explicit-copy branch from 9316626 to c924934 Compare February 16, 2026 22:10
@Repiteo Repiteo modified the milestones: 4.x, 4.7 Feb 17, 2026
@Repiteo Repiteo merged commit 23d7147 into godotengine:master Feb 17, 2026
20 checks passed
@Repiteo

Repiteo commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Thanks!

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