Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2617)

Unified Diff: Source/platform/weborigin/KnownPorts.cpp

Issue 895793003: Simplify protocal name and port comparison (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/weborigin/KnownPorts.cpp
diff --git a/Source/platform/weborigin/KnownPorts.cpp b/Source/platform/weborigin/KnownPorts.cpp
index 71499a5120c0c30971113663f74560f12173b096..b289ef258891c62030bfa5cd626009e1ea196df3 100644
--- a/Source/platform/weborigin/KnownPorts.cpp
+++ b/Source/platform/weborigin/KnownPorts.cpp
@@ -40,15 +40,16 @@ bool isDefaultPortForProtocol(unsigned short port, const String& protocol)
if (protocol.isEmpty())
return false;
- typedef HashMap<String, unsigned, CaseFoldingHash> DefaultPortsMap;
- AtomicallyInitializedStaticReference(DefaultPortsMap, defaultPorts, new DefaultPortsMap());
- if (defaultPorts.isEmpty()) {
- defaultPorts.set("http", 80);
- defaultPorts.set("https", 443);
- defaultPorts.set("ftp", 21);
- defaultPorts.set("ftps", 990);
- }
- return defaultPorts.get(protocol) == port;
+ if (protocol == "http")
+ return port == 80;
+ if (protocol == "https")
+ return port == 443;
+ if (protocol == "ftp")
+ return port == 21;
+ if (protocol == "ftps")
+ return port == 990;
kinuko 2015/02/03 03:52:32 Switching on port number, and then comparing proto
Ian Wen 2015/02/03 19:08:54 Indeed. Done.
+
+ return false;
}
bool portAllowed(const KURL& url)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698