Remove redundant directory separator normalization in deps.json parsing#125251
Remove redundant directory separator normalization in deps.json parsing#125251elinor-fung merged 3 commits intodotnet:mainfrom
Conversation
Normalize paths to the platform separator (DIR_SEPARATOR) once in the deps_asset_t constructor instead of storing them with '/' and re-normalizing on every use. Previously: - The constructor normalized '\\' -> '/' (canonical form) - get_optional_path() normalized '/' -> DIR_SEPARATOR at parse time (for local_path, undone by the constructor) - normalize_dir_separator() converted '/' -> DIR_SEPARATOR on every call to to_dir_path() and to_package_path(), allocating a new string each time Now: - The constructor normalizes directly to DIR_SEPARATOR (one allocation) - normalize_dir_separator() is removed entirely - get_deps_filename() is removed in favor of the equivalent get_filename() - Placeholder checks updated to use DIR_SEPARATOR instead of hardcoded '/' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Restructure to_dir_path to pass const references directly to to_path when the relative path doesn't need modification (local_path set, or runtimepack). This eliminates a string allocation per call in those two fast paths. Also fix 'helperthat' typo in deps_resolver.cpp comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung |
There was a problem hiding this comment.
Pull request overview
This PR optimizes startup performance by normalizing directory separator characters in deps.json paths exactly once in the deps_asset_t constructor (to the platform's DIR_SEPARATOR), rather than normalizing from '/' to DIR_SEPARATOR on every access. This removes the normalize_dir_separator helper function and the get_deps_filename helper function, and updates placeholder detection and path-utility calls to work with already-platform-normalized paths.
Changes:
deps_entry.h: Thedeps_asset_tconstructor now normalizesrelative_pathandlocal_pathtoDIR_SEPARATORin place of the previous'/'-normalizationdeps_entry.cpp: Removesnormalize_dir_separator(), usesasset.relative_pathdirectly, and refactorsto_dir_pathfor claritydeps_resolver.cpp: Removesget_deps_filename(), updates placeholder checks from"/_._"toDIR_SEPARATOR_STR "_._", and replacesget_deps_filenamewithget_filename
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/native/corehost/hostpolicy/deps_entry.h |
Constructor normalizes paths to platform separator once (instead of storing with '/' and converting on every use) |
src/native/corehost/hostpolicy/deps_entry.cpp |
Removes normalize_dir_separator(), refactors to_dir_path to use pre-normalized paths, simplifies to_package_path |
src/native/corehost/hostpolicy/deps_resolver.cpp |
Removes get_deps_filename(), fixes placeholder suffix check for platform-normalized paths |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
You can also share your feedback on Copilot code review. Take the survey.
Normalize paths to the platform separator (DIR_SEPARATOR) once in the
deps_asset_t constructor instead of normalizing them to '/` to store them
and re-normalizing to platform separator on every use.
Removes >400 allocations on startup.
@dotnet/appmodel @AaronRobinsonMSFT