Skip to content

Use BTreeMap instead of HashMap - #1840

Merged
sdroege merged 1 commit into
gtk-rs:mainfrom
bmwiedemann:hashmap
Oct 30, 2025
Merged

sdroege merged 1 commit into
gtk-rs:mainfrom
bmwiedemann:hashmap

Conversation

@bmwiedemann

Copy link
Copy Markdown
Contributor

Use BTreeMap instead of HashMap
to have deterministic output ordering
to allow for reproducible builds.

See https://reproducible-builds.org/ for why this is good.

Without this patch, ArchLinux' and openSUSE's identity package varied between builds.

Special thanks go to @kpcyrd for help in debugging this.

to have deterministic output ordering
to allow for reproducible builds.

See https://reproducible-builds.org/ for why this is good.

Without this patch, ArchLinux' and openSUSE's identity package varied between builds.
@sdroege sdroege added the needs-backport PR needs backporting to the current stable branch label Oct 30, 2025
@sdroege
sdroege merged commit 8a033dc into gtk-rs:main Oct 30, 2025
47 of 48 checks passed
@sdroege

sdroege commented Oct 30, 2025

Copy link
Copy Markdown
Member

Thanks, I'll include this in the next bugfix release :)

@sdroege

sdroege commented Oct 30, 2025

Copy link
Copy Markdown
Member

I wonder if this shouldn't actually use https://docs.rs/indexmap so that the order from the user is preserved

@sdroege sdroege added backported PR was backported to the current stable branch and removed needs-backport PR needs backporting to the current stable branch labels Oct 30, 2025
@bmwiedemann

Copy link
Copy Markdown
Contributor Author

I did some more testing and found that this patch helps to make more openSUSE package builds fully deterministic: mousai identity eww Fragments fractal gstreamer-plugins-rs contrast

Regarding IndexMap:
users had random ordering before, so my guess is that they do not care much if it is alphabetic or insertion order. And performance is not a concern during build (assuming this code is only used during build).

@bmwiedemann
bmwiedemann deleted the hashmap branch October 31, 2025 11:43
@sdroege

sdroege commented Oct 31, 2025

Copy link
Copy Markdown
Member

It's only used during builds, yes.

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

Labels

backported PR was backported to the current stable branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants