Skip to content

Eliminate some unnecessary allocations in AssetPath - #25742

Open
Mysvac wants to merge 1 commit into
bevyengine:mainfrom
Mysvac:asset_path
Open

Eliminate some unnecessary allocations in AssetPath#25742
Mysvac wants to merge 1 commit into
bevyengine:mainfrom
Mysvac:asset_path

Conversation

@Mysvac

@Mysvac Mysvac commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Objective

Eliminate some unnecessary memory allocations in AssetPath's methods (bevy_asset).

AssetPath::parent

Converting &Path directly to Arc<Path> is the fastest approach, requiring only one allocation.
But the current implementation is &Path -> PathBuf -> Arc<Path>, which requires two.

The PathBuf -> Arc<Path> step requires an allocation and a copy; see the standard library implementation for details.

AssetPath::is_unapproved

Currently, using PathBuf as a stack is unnecessary. Switching to an integer counter is sufficient.

Solution

See FileChanged for details — the change is minimal.

Testing

None

@Mysvac Mysvac changed the title Eliminate one allocation in AssetPath::parent Eliminate some unnecessary allocation in AssetPath Sep 10, 2026
@Mysvac Mysvac changed the title Eliminate some unnecessary allocation in AssetPath Eliminate some unnecessary allocations in AssetPath Sep 10, 2026
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