More misc optimizations

This commit is contained in:
JustArchi
2020-03-06 00:06:39 +01:00
parent ce18794e3c
commit b0ef7309b8

View File

@@ -1716,13 +1716,17 @@ namespace ArchiSteamFarm {
const string request = "/gifts";
HtmlDocument response = await UrlGetToHtmlDocumentWithSession(SteamStoreURL, request).ConfigureAwait(false);
HtmlNodeCollection htmlNodes = response?.DocumentNode.SelectNodes("//div[@class='pending_gift']/div[starts-with(@id, 'pending_gift_')][count(div[@class='pending_giftcard_leftcol']) > 0]/@id");
if (htmlNodes == null) {
if (response == null) {
return null;
}
HashSet<ulong> results = new HashSet<ulong>();
HtmlNodeCollection htmlNodes = response.DocumentNode.SelectNodes("//div[@class='pending_gift']/div[starts-with(@id, 'pending_gift_')][count(div[@class='pending_giftcard_leftcol']) > 0]/@id");
if (htmlNodes == null) {
return new HashSet<ulong>(0);
}
HashSet<ulong> results = new HashSet<ulong>(htmlNodes.Count);
foreach (string giftCardIDText in htmlNodes.Select(node => node.GetAttributeValue("id", null))) {
if (string.IsNullOrEmpty(giftCardIDText)) {
@@ -1766,13 +1770,13 @@ namespace ArchiSteamFarm {
HtmlNodeCollection htmlNodes = htmlDocument.DocumentNode.SelectNodes("(//table[@class='accountTable'])[2]//a/@data-miniprofile");
HashSet<ulong> result = new HashSet<ulong>();
if (htmlNodes == null) {
// OK, no authorized steamIDs
return result;
return new HashSet<ulong>(0);
}
HashSet<ulong> result = new HashSet<ulong>(htmlNodes.Count);
foreach (string miniProfile in htmlNodes.Select(htmlNode => htmlNode.GetAttributeValue("data-miniprofile", null))) {
if (string.IsNullOrEmpty(miniProfile)) {
Bot.ArchiLogger.LogNullError(nameof(miniProfile));