@@ -65,7 +65,7 @@ namespace duckdb
6565 }
6666 else
6767 {
68- // For /32, the IP itself is the only host ( Hostroute )
68+ // For /32, the IP itself is the only host (Hostroute)
6969 info.network = ip;
7070 }
7171
@@ -74,7 +74,7 @@ namespace duckdb
7474
7575 bool IPCalculator::isValidInput (const std::string &input)
7676 {
77- std::regex pattern (R"( (\d{1,3}\.){3}\d{1,3}(/\d{1,2})?)" );
77+ static const std::regex pattern (R"( (\d{1,3}\.){3}\d{1,3}(/\d{1,2})?)" );
7878 return std::regex_match (input, pattern);
7979 }
8080
@@ -91,14 +91,15 @@ namespace duckdb
9191 return true ;
9292 }
9393
94- std::vector <int > IPCalculator::parseIP (const std::string &ip)
94+ std::array <int , 4 > IPCalculator::parseIP (const std::string &ip)
9595 {
96- std::vector <int > octets;
96+ std::array <int , 4 > octets{} ;
9797 std::stringstream ss (ip);
9898 std::string octet;
99- while ( std::getline (ss, octet, ' . ' ) )
99+ for ( int i = 0 ; i < 4 ; ++i )
100100 {
101- octets.push_back (std::stoi (octet));
101+ std::getline (ss, octet, ' .' );
102+ octets[i] = std::stoi (octet);
102103 }
103104 return octets;
104105 }
@@ -190,7 +191,7 @@ namespace duckdb
190191 return ss.str ();
191192 }
192193
193- std::string IPCalculator::intToIP (const std::vector <int > &octets)
194+ std::string IPCalculator::intToIP (const std::array <int , 4 > &octets)
194195 {
195196 std::stringstream ss;
196197 for (int i = 0 ; i < 4 ; ++i)
0 commit comments