Skip to content

libstore: reduce allocations in StoreDirConfig::printStorePath#14825

Closed
Zaczero wants to merge 1 commit intoNixOS:masterfrom
Zaczero:zaczero/libstore-printstorepath
Closed

libstore: reduce allocations in StoreDirConfig::printStorePath#14825
Zaczero wants to merge 1 commit intoNixOS:masterfrom
Zaczero:zaczero/libstore-printstorepath

Conversation

@Zaczero
Copy link
Member

@Zaczero Zaczero commented Dec 18, 2025

StoreDirConfig::printStorePath() previously built an intermediate string via storeDir + "/" and then appended the store-path basename, which can trigger an extra allocation/copy.

Motivation

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

StoreDirConfig::printStorePath() previously built an intermediate string via storeDir + "/" and then appended the store-path basename, which can trigger an extra allocation/copy.
@Zaczero Zaczero requested a review from Ericson2314 as a code owner December 18, 2025 02:53
@xokdvium
Copy link
Contributor

Also sounds good, though I doubt this would have lead to extra allocations because of small string optimization (libstdc++ stores 16 bytes inline iirc, something similar for libc++). Still this should have one less copy constructor which is good.

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but I think we can shorten it while not loosing the benefits: see concatStrings. If you follow the templates, it does the same thing.

@Zaczero
Copy link
Member Author

Zaczero commented Dec 18, 2025

I merged this PR with #14823

@Zaczero Zaczero closed this Dec 18, 2025
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.

3 participants