Make folly::Uri::port() return uint16_t instead of uint32_t.
authorStephane Sezer <sas@fb.com>
Thu, 19 Sep 2013 19:19:26 +0000 (12:19 -0700)
committerJordan DeLong <jdelong@fb.com>
Sun, 22 Sep 2013 23:40:23 +0000 (16:40 -0700)
Summary: We can safely assume that ports are always going to be 16bit (TCP or UDP), so no need to have a uint32_t here.

Test Plan: Ran tests in folly/tests.

Reviewed By: tudorb@fb.com

FB internal diff: D973291

folly/Uri.cpp
folly/Uri.h

index 9ae5c713d1d6042b4212949b8193e7a8aa5f4b4a..a94c9308fb0f84fa3445bb435209d5a24b94fd28 100644 (file)
@@ -79,7 +79,7 @@ Uri::Uri(StringPiece str) : port_(0) {
 
     StringPiece port(authorityMatch[4].first, authorityMatch[4].second);
     if (!port.empty()) {
-      port_ = to<uint32_t>(port);
+      port_ = to<uint16_t>(port);
     }
 
     username_ = submatch(authorityMatch, 1);
index 8885bb9f40d235afd0f47137f1c596ebc78cdd6f..5ed0a1b7af54aa221338c52c50328888eea42e0e 100644 (file)
@@ -48,7 +48,7 @@ class Uri {
   const fbstring& username() const { return username_; }
   const fbstring& password() const { return password_; }
   const fbstring& host() const { return host_; }
-  uint32_t port() const { return port_; }
+  uint16_t port() const { return port_; }
   const fbstring& path() const { return path_; }
   const fbstring& query() const { return query_; }
   const fbstring& fragment() const { return fragment_; }
@@ -64,7 +64,7 @@ class Uri {
   fbstring username_;
   fbstring password_;
   fbstring host_;
-  uint32_t port_;
+  uint16_t port_;
   fbstring path_;
   fbstring query_;
   fbstring fragment_;