Bug 1362806 - Optimize NS_GetDefaultPort() for HTTP(S); r=mcmanus

This commit is contained in:
Ehsan Akhgari 2017-05-06 18:49:19 -04:00
Родитель 8069f421a8
Коммит e0f12d7786
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -476,6 +476,18 @@ NS_GetDefaultPort(const char *scheme,
{ {
nsresult rv; nsresult rv;
// Getting the default port through the protocol handler has a lot of XPCOM
// overhead involved. We optimize the protocols that matter for Web pages
// (HTTP and HTTPS) by hardcoding their default ports here.
if (strncmp(scheme, "http", 4) == 0) {
if (scheme[4] == 's' && scheme[5] == '\0') {
return 443;
}
if (scheme[4] == '\0') {
return 80;
}
}
nsCOMPtr<nsIIOService> grip; nsCOMPtr<nsIIOService> grip;
net_EnsureIOService(&ioService, grip); net_EnsureIOService(&ioService, grip);
if (!ioService) if (!ioService)