Skip to content

Commit 4c2f685

Browse files
committed
smarter fetching, stop when we have a good favicon
1 parent 84a47b4 commit 4c2f685

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Services/FaviconService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,15 @@ private List<FaviconCandidate> ParseLinkTags(string htmlContent, Uri originalBas
399399
continue;
400400
}
401401

402-
candidates.Add(new FaviconCandidate(fullUrl.ToString(), CalculateFaviconScore(linkTag, fullUrl.ToString())));
402+
var score = CalculateFaviconScore(linkTag, fullUrl.ToString());
403+
candidates.Add(new FaviconCandidate(fullUrl.ToString(), score));
404+
405+
// If we find a candidate that is likely high quality, stop parsing the rest of the HTML.
406+
if (score >= TargetIconSize)
407+
{
408+
_context.API.LogDebug(nameof(ParseLinkTags), $"Found suitable favicon candidate (score: {score}). Halting further HTML parsing.");
409+
break;
410+
}
403411
}
404412

405413
return candidates;

0 commit comments

Comments
 (0)