Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
This commit is contained in:
@@ -100,7 +100,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // GE
|
||||
if (ifa->ifa_broadaddr->sa_family != AF_INET) continue;
|
||||
|
||||
NetworkAddress addr(ifa->ifa_broadaddr, sizeof(sockaddr));
|
||||
if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) *broadcast->Append() = addr;
|
||||
if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr);
|
||||
}
|
||||
freeifaddrs(ifap);
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ TCPConnecter::TCPConnecter(const NetworkAddress &address) :
|
||||
sock(INVALID_SOCKET),
|
||||
address(address)
|
||||
{
|
||||
*_tcp_connecters.Append() = this;
|
||||
_tcp_connecters.push_back(this);
|
||||
if (!ThreadObject::New(TCPConnecter::ThreadEntry, this, &this->thread, "ottd:tcp")) {
|
||||
this->Connect();
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
|
||||
return;
|
||||
}
|
||||
|
||||
*_http_connections.Append() = this;
|
||||
_http_connections.push_back(this);
|
||||
}
|
||||
|
||||
/** Free whatever needs to be freed. */
|
||||
|
@@ -26,14 +26,14 @@ NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind)
|
||||
{
|
||||
if (bind != NULL) {
|
||||
for (NetworkAddress *addr = bind->Begin(); addr != bind->End(); addr++) {
|
||||
*this->bind.Append() = *addr;
|
||||
this->bind.push_back(*addr);
|
||||
}
|
||||
} else {
|
||||
/* As hostname NULL and port 0/NULL don't go well when
|
||||
* resolving it we need to add an address for each of
|
||||
* the address families we support. */
|
||||
*this->bind.Append() = NetworkAddress(NULL, 0, AF_INET);
|
||||
*this->bind.Append() = NetworkAddress(NULL, 0, AF_INET6);
|
||||
this->bind.emplace_back(nullptr, 0, AF_INET);
|
||||
this->bind.emplace_back(nullptr, 0, AF_INET6);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -633,12 +633,12 @@ void NetworkAddServer(const char *b)
|
||||
void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
|
||||
{
|
||||
for (char **iter = _network_bind_list.Begin(); iter != _network_bind_list.End(); iter++) {
|
||||
*addresses->Append() = NetworkAddress(*iter, port);
|
||||
addresses->emplace_back(*iter, port);
|
||||
}
|
||||
|
||||
/* No address, so bind to everything. */
|
||||
if (addresses->size() == 0) {
|
||||
*addresses->Append() = NetworkAddress("", port);
|
||||
addresses->emplace_back("", port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ void NetworkRebuildHostList()
|
||||
_network_host_list.Clear();
|
||||
|
||||
for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
|
||||
if (item->manually) *_network_host_list.Append() = stredup(item->address.GetAddressAsString(false));
|
||||
if (item->manually) _network_host_list.push_back(stredup(item->address.GetAddressAsString(false)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ struct PacketReader : LoadFilter {
|
||||
/* Allocate a new chunk and add the remaining data. */
|
||||
pbuf += to_write;
|
||||
to_write = in_packet - to_write;
|
||||
this->buf = *this->blocks.Append() = CallocT<byte>(CHUNK);
|
||||
this->blocks.push_back(this->buf = CallocT<byte>(CHUNK));
|
||||
this->bufe = this->buf + CHUNK;
|
||||
|
||||
memcpy(this->buf, pbuf, to_write);
|
||||
|
@@ -165,7 +165,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
|
||||
return true;
|
||||
}
|
||||
|
||||
*this->infos.Append() = ci;
|
||||
this->infos.push_back(ci);
|
||||
|
||||
/* Incoming data means that we might need to reconsider dependencies */
|
||||
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||
@@ -278,7 +278,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
*this->infos.Append() = ci;
|
||||
this->infos.push_back(ci);
|
||||
} else {
|
||||
delete ci;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
||||
const ContentInfo *ci = *iter;
|
||||
if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
|
||||
|
||||
*content.Append() = ci->id;
|
||||
content.push_back(ci->id);
|
||||
bytes += ci->filesize;
|
||||
}
|
||||
|
||||
@@ -579,11 +579,11 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
||||
if (this->http_response_index == -1) {
|
||||
if (data != NULL) {
|
||||
/* Append the rest of the response. */
|
||||
memcpy(this->http_response.Append((uint)length), data, length);
|
||||
memcpy(grow(this->http_response, (uint)length), data, length);
|
||||
return;
|
||||
} else {
|
||||
/* Make sure the response is properly terminated. */
|
||||
*this->http_response.Append() = '\0';
|
||||
this->http_response.push_back('\0');
|
||||
|
||||
/* And prepare for receiving the rest of the data. */
|
||||
this->http_response_index = 0;
|
||||
@@ -905,7 +905,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
|
||||
|
||||
for (uint i = 0; i < ci->dependency_count; i++) {
|
||||
if (ci->dependencies[i] == child->id) {
|
||||
*parents.Append() = ci;
|
||||
parents.push_back(ci);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -919,7 +919,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
|
||||
*/
|
||||
void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
|
||||
{
|
||||
*tree.Append() = child;
|
||||
tree.push_back(child);
|
||||
|
||||
/* First find all direct parents. We can't use the "normal" iterator as
|
||||
* we are including stuff into the vector and as such the vector's data
|
||||
|
@@ -391,7 +391,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
|
||||
|
||||
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||
if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false;
|
||||
*this->content.Append() = *iter;
|
||||
this->content.push_back(*iter);
|
||||
}
|
||||
|
||||
this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available);
|
||||
|
@@ -253,7 +253,7 @@ protected:
|
||||
this->servers.clear();
|
||||
|
||||
for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) {
|
||||
*this->servers.Append() = ngl;
|
||||
this->servers.push_back(ngl);
|
||||
}
|
||||
|
||||
/* Apply the filter condition immediately, if a search string has been provided. */
|
||||
@@ -1737,9 +1737,7 @@ struct NetworkClientListPopupWindow : Window {
|
||||
*/
|
||||
inline void AddAction(StringID name, ClientList_Action_Proc *proc)
|
||||
{
|
||||
ClientListAction *action = this->actions.Append();
|
||||
action->name = name;
|
||||
action->proc = proc;
|
||||
this->actions.push_back({name, proc});
|
||||
}
|
||||
|
||||
NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) :
|
||||
|
@@ -2101,7 +2101,7 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!contains) *_network_ban_list.Append() = stredup(ip);
|
||||
if (!contains) _network_ban_list.push_back(stredup(ip));
|
||||
}
|
||||
|
||||
uint n = 0;
|
||||
|
Reference in New Issue
Block a user