Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid creation of temporary strings where possible #11380

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Build/BackEnd/Shared/BuildRequestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ public bool IsTraversal
{
if (!_isTraversalProject.HasValue)
{
if (String.Equals(Path.GetFileName(ProjectFullPath), "dirs.proj", StringComparison.OrdinalIgnoreCase))
#if NET471_OR_GREATER
if (MemoryExtensions.Equals(Microsoft.IO.Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj".AsSpan(), StringComparison.OrdinalIgnoreCase))
JanProvaznik marked this conversation as resolved.
Show resolved Hide resolved
#else
if (MemoryExtensions.Equals(Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj", StringComparison.OrdinalIgnoreCase))
#endif
{
// dirs.proj are assumed to be traversals
_isTraversalProject = true;
Expand Down
9 changes: 6 additions & 3 deletions src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,15 +1223,18 @@ private void EnsureParameterInitialized(TaskPropertyInfo parameter, Lookup looku

string taskAndParameterName = _taskName + "_" + parameter.Name;
string key = "DisableLogTaskParameter_" + taskAndParameterName;
string metadataKey = "DisableLogTaskParameterItemMetadata_" + taskAndParameterName;

if (string.Equals(lookup.GetProperty(key)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
{
parameter.Log = false;
}
else if (string.Equals(lookup.GetProperty(metadataKey)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
else
{
parameter.LogItemMetadata = false;
string metadataKey = "DisableLogTaskParameterItemMetadata_" + taskAndParameterName;
if (string.Equals(lookup.GetProperty(metadataKey)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
{
parameter.LogItemMetadata = false;
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Tasks/SystemState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,7 @@ private AssemblyNameExtension GetAssemblyName(string path)
// then we can short-circuit the File IO involved with GetAssemblyName()
if (redistList != null)
{
string extension = Path.GetExtension(path);

if (string.Equals(extension, ".dll", StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrEmpty(path) && path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
JanProvaznik marked this conversation as resolved.
Show resolved Hide resolved
{
IEnumerable<AssemblyEntry> assemblyNames = redistList.FindAssemblyNameFromSimpleName(
Path.GetFileNameWithoutExtension(path));
Expand Down