Skip to content

Commit df39ef8

Browse files
authored
Avoid creation of temporary strings where possible (#11380)
1 parent a8b0614 commit df39ef8

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/Build/BackEnd/Shared/BuildRequestConfiguration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ public bool IsTraversal
299299
{
300300
if (!_isTraversalProject.HasValue)
301301
{
302-
if (String.Equals(Path.GetFileName(ProjectFullPath), "dirs.proj", StringComparison.OrdinalIgnoreCase))
302+
#if NET471_OR_GREATER
303+
if (MemoryExtensions.Equals(Microsoft.IO.Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj".AsSpan(), StringComparison.OrdinalIgnoreCase))
304+
#else
305+
if (MemoryExtensions.Equals(Path.GetFileName(ProjectFullPath.AsSpan()), "dirs.proj", StringComparison.OrdinalIgnoreCase))
306+
#endif
303307
{
304308
// dirs.proj are assumed to be traversals
305309
_isTraversalProject = true;

src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,15 +1223,18 @@ private void EnsureParameterInitialized(TaskPropertyInfo parameter, Lookup looku
12231223

12241224
string taskAndParameterName = _taskName + "_" + parameter.Name;
12251225
string key = "DisableLogTaskParameter_" + taskAndParameterName;
1226-
string metadataKey = "DisableLogTaskParameterItemMetadata_" + taskAndParameterName;
12271226

12281227
if (string.Equals(lookup.GetProperty(key)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
12291228
{
12301229
parameter.Log = false;
12311230
}
1232-
else if (string.Equals(lookup.GetProperty(metadataKey)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
1231+
else
12331232
{
1234-
parameter.LogItemMetadata = false;
1233+
string metadataKey = "DisableLogTaskParameterItemMetadata_" + taskAndParameterName;
1234+
if (string.Equals(lookup.GetProperty(metadataKey)?.EvaluatedValue, "true", StringComparison.OrdinalIgnoreCase))
1235+
{
1236+
parameter.LogItemMetadata = false;
1237+
}
12351238
}
12361239
}
12371240

src/Tasks/SystemState.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,7 @@ private AssemblyNameExtension GetAssemblyName(string path)
456456
// then we can short-circuit the File IO involved with GetAssemblyName()
457457
if (redistList != null)
458458
{
459-
string extension = Path.GetExtension(path);
460-
461-
if (string.Equals(extension, ".dll", StringComparison.OrdinalIgnoreCase))
459+
if (!string.IsNullOrEmpty(path) && path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
462460
{
463461
IEnumerable<AssemblyEntry> assemblyNames = redistList.FindAssemblyNameFromSimpleName(
464462
Path.GetFileNameWithoutExtension(path));

0 commit comments

Comments
 (0)