diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2017-05-04 14:12:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-05-04 15:17:49 (GMT) |
commit | 3e027d9def0f2d9f542cb71eda12e9527c418c9e (patch) | |
tree | 5e1baea6d8eb68854e5ff0f13729b23a2fffdff4 /Source/cmFileCommand.cxx | |
parent | ec526768ac5f1e00a39075cd07fd93cffa1f1818 (diff) | |
download | CMake-3e027d9def0f2d9f542cb71eda12e9527c418c9e.zip CMake-3e027d9def0f2d9f542cb71eda12e9527c418c9e.tar.gz CMake-3e027d9def0f2d9f542cb71eda12e9527c418c9e.tar.bz2 |
c++: prefer vectors over lists
None of these usages of `std::list` were inserting or removing elements
in the middle of the structure, so there were no benefits to using it.
Other uses were related to C pointers being stable in a list of strings
whereas in a vector of strings, small pointer optimizations could be
moved and become invalid after a modification to the hosting vector.
None of these uses modified the vector after handing out a C string to
an external store.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fa166a0..2c25e9b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -10,11 +10,11 @@ #include "cmsys/String.hxx" #include <algorithm> #include <assert.h> -#include <list> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <vector> #include "cmAlgorithms.h" #include "cmCommandArgumentsHelper.h" @@ -2618,7 +2618,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) bool showProgress = false; std::string userpwd; - std::list<std::string> curl_headers; + std::vector<std::string> curl_headers; while (i != args.end()) { if (*i == "TIMEOUT") { @@ -2862,7 +2862,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) } struct curl_slist* headers = CM_NULLPTR; - for (std::list<std::string>::const_iterator h = curl_headers.begin(); + for (std::vector<std::string>::const_iterator h = curl_headers.begin(); h != curl_headers.end(); ++h) { headers = ::curl_slist_append(headers, h->c_str()); } @@ -2952,7 +2952,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) bool showProgress = false; std::string userpwd; - std::list<std::string> curl_headers; + std::vector<std::string> curl_headers; while (i != args.end()) { if (*i == "TIMEOUT") { @@ -3120,7 +3120,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) } struct curl_slist* headers = CM_NULLPTR; - for (std::list<std::string>::const_iterator h = curl_headers.begin(); + for (std::vector<std::string>::const_iterator h = curl_headers.begin(); h != curl_headers.end(); ++h) { headers = ::curl_slist_append(headers, h->c_str()); } |