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

remove redundant ToArray #9998

Merged
merged 5 commits into from
Jun 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public async Task SaveAuditRecordAsync(AuditRecord record)
throw new ArgumentNullException(nameof(record));
}

var tasks = _services.Select(service => service.SaveAuditRecordAsync(record))
.ToArray();

var tasks = _services.Select(service => service.SaveAuditRecordAsync(record));
await Task.WhenAll(tasks);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public virtual async Task RemoveCredential(User user, Credential cred, bool comm

public virtual async Task EditCredentialScopes(User user, Credential cred, ICollection<Scope> newScopes)
{
foreach (var oldScope in cred.Scopes.ToArray())
foreach (var oldScope in cred.Scopes)
{
Entities.Scopes.Remove(oldScope);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ protected override void AttachToOwinApp(IGalleryConfigurationService config, IAp
.Current
.AlternateSiteRootList
.Split(';')
.Select(d => d.Trim())
.ToArray();
.Select(d => d.Trim());

_alternateSiteRootList = new HashSet<string>(alternateSiteRootList, StringComparer.OrdinalIgnoreCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static string Flatten(this IEnumerable<string> list)
return String.Empty;
}

return String.Join(", ", list.ToArray());
return String.Join(", ", list);
}

public static HelperResult Flatten<T>(this IEnumerable<T> items, Func<T, HelperResult> template)
Expand All @@ -34,7 +34,7 @@ public static HelperResult Flatten<T>(this IEnumerable<T> items, Func<T, HelperR
}
var formattedItems = items.Select(item => template(item).ToHtmlString());

return new HelperResult(writer => { writer.Write(String.Join(", ", formattedItems.ToArray())); });
return new HelperResult(writer => { writer.Write(String.Join(", ", formattedItems)); });
}

public static bool AnySafe<T>(this IEnumerable<T> items)
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery.Services/Storage/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private async Task<IHtmlString> GetContentItemCore(string name, string[] extensi
Trace.Verbose("Cache Expired.");

// Get the file from the content service
var filenames = extensions.Select(extension => name + extension).ToArray();
var filenames = extensions.Select(extension => name + extension);

foreach (var filename in filenames)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public JsonResult Verify(string verifyQuery)
return Json(HttpStatusCode.BadRequest, "Invalid empty input!");
}

var queries = verifyQuery.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(q => q.Trim()).ToList();
var queries = verifyQuery.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(q => q.Trim());

var results = new List<ApiKeyRevokeViewModel>();
var verifiedApiKey = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
Expand Down