mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Prefer specific [io]stringstream where possible
These better communicate intent and are slightly more efficient.
This commit is contained in:
parent
a442e843be
commit
07636c8a8d
@ -93,7 +93,7 @@ bool AdditionalHeader::Load(const char* file)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// load a line
|
// load a line
|
||||||
stringstream ss(line);
|
istringstream ss(line);
|
||||||
string key; // suffix(key)
|
string key; // suffix(key)
|
||||||
string head; // additional HTTP header
|
string head; // additional HTTP header
|
||||||
string value; // header value
|
string value; // header value
|
||||||
@ -245,7 +245,7 @@ bool AdditionalHeader::Dump(void) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringstream ssdbg;
|
ostringstream ssdbg;
|
||||||
int cnt = 1;
|
int cnt = 1;
|
||||||
|
|
||||||
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << endl;
|
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << endl;
|
||||||
|
@ -611,7 +611,7 @@ bool S3fsCurl::InitMimeType(const char* MimeFile)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringstream tmp(line);
|
istringstream tmp(line);
|
||||||
string mimeType;
|
string mimeType;
|
||||||
tmp >> mimeType;
|
tmp >> mimeType;
|
||||||
while(tmp){
|
while(tmp){
|
||||||
@ -808,7 +808,7 @@ size_t S3fsCurl::HeaderCallback(void* data, size_t blockSize, size_t numBlocks,
|
|||||||
headers_t* headers = reinterpret_cast<headers_t*>(userPtr);
|
headers_t* headers = reinterpret_cast<headers_t*>(userPtr);
|
||||||
string header(reinterpret_cast<char*>(data), blockSize * numBlocks);
|
string header(reinterpret_cast<char*>(data), blockSize * numBlocks);
|
||||||
string key;
|
string key;
|
||||||
stringstream ss(header);
|
istringstream ss(header);
|
||||||
|
|
||||||
if(getline(ss, key, ':')){
|
if(getline(ss, key, ':')){
|
||||||
// Force to lower, only "x-amz"
|
// Force to lower, only "x-amz"
|
||||||
@ -3681,7 +3681,7 @@ int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& met
|
|||||||
off_t chunk;
|
off_t chunk;
|
||||||
off_t bytes_remaining;
|
off_t bytes_remaining;
|
||||||
etaglist_t list;
|
etaglist_t list;
|
||||||
stringstream strrange;
|
ostringstream strrange;
|
||||||
|
|
||||||
S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath));
|
S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath));
|
||||||
|
|
||||||
@ -3814,7 +3814,7 @@ int S3fsCurl::MultipartRenameRequest(const char* from, const char* to, headers_t
|
|||||||
off_t chunk;
|
off_t chunk;
|
||||||
off_t bytes_remaining;
|
off_t bytes_remaining;
|
||||||
etaglist_t list;
|
etaglist_t list;
|
||||||
stringstream strrange;
|
ostringstream strrange;
|
||||||
|
|
||||||
S3FS_PRN_INFO3("[from=%s][to=%s]", SAFESTRPTR(from), SAFESTRPTR(to));
|
S3FS_PRN_INFO3("[from=%s][to=%s]", SAFESTRPTR(from), SAFESTRPTR(to));
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
|
|||||||
//
|
//
|
||||||
// put to file
|
// put to file
|
||||||
//
|
//
|
||||||
stringstream ssall;
|
ostringstream ssall;
|
||||||
ssall << Size();
|
ssall << Size();
|
||||||
|
|
||||||
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ++iter){
|
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ++iter){
|
||||||
@ -544,7 +544,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string oneline;
|
string oneline;
|
||||||
stringstream ssall(ptmp);
|
istringstream ssall(ptmp);
|
||||||
|
|
||||||
// loaded
|
// loaded
|
||||||
Clear();
|
Clear();
|
||||||
@ -561,7 +561,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output)
|
|||||||
bool is_err = false;
|
bool is_err = false;
|
||||||
while(getline(ssall, oneline, '\n')){
|
while(getline(ssall, oneline, '\n')){
|
||||||
string part;
|
string part;
|
||||||
stringstream ssparts(oneline);
|
istringstream ssparts(oneline);
|
||||||
// offset
|
// offset
|
||||||
if(!getline(ssparts, part, ':')){
|
if(!getline(ssparts, part, ':')){
|
||||||
is_err = true;
|
is_err = true;
|
||||||
|
@ -611,7 +611,7 @@ int mkdirp(const string& path, mode_t mode)
|
|||||||
{
|
{
|
||||||
string base;
|
string base;
|
||||||
string component;
|
string component;
|
||||||
stringstream ss(path);
|
istringstream ss(path);
|
||||||
while (getline(ss, component, '/')) {
|
while (getline(ss, component, '/')) {
|
||||||
base += "/" + component;
|
base += "/" + component;
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ string get_exist_directory_path(const string& path)
|
|||||||
string existed("/"); // "/" is existed.
|
string existed("/"); // "/" is existed.
|
||||||
string base;
|
string base;
|
||||||
string component;
|
string component;
|
||||||
stringstream ss(path);
|
istringstream ss(path);
|
||||||
while (getline(ss, component, '/')) {
|
while (getline(ss, component, '/')) {
|
||||||
if(base != "/"){
|
if(base != "/"){
|
||||||
base += "/";
|
base += "/";
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template <class T> std::string str(T value) {
|
template <class T> std::string str(T value) {
|
||||||
std::stringstream s;
|
std::ostringstream s;
|
||||||
s << value;
|
s << value;
|
||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user