Use const std::string& where possible

This hints to callers on usage.
This commit is contained in:
Andrew Gaul 2020-09-14 17:47:21 +09:00
parent 757f4caee8
commit 8d2bd874d7
6 changed files with 12 additions and 13 deletions

View File

@ -163,7 +163,7 @@ class StatCache
// Delete stat cache
bool DelStat(const char* key, bool lock_already_held = false);
bool DelStat(std::string& key, bool lock_already_held = false)
bool DelStat(const std::string& key, bool lock_already_held = false)
{
return DelStat(key.c_str(), lock_already_held);
}

View File

@ -761,9 +761,9 @@ storage_class_t S3fsCurl::SetStorageClass(storage_class_t storage_class)
return old;
}
bool S3fsCurl::PushbackSseKeys(std::string& onekey)
bool S3fsCurl::PushbackSseKeys(const std::string& input)
{
onekey = trim(onekey);
std::string onekey = trim(input);
if(onekey.empty()){
return false;
}
@ -2772,8 +2772,9 @@ bool S3fsCurl::LoadIAMRoleFromMetaData()
return (0 == result);
}
bool S3fsCurl::AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy)
bool S3fsCurl::AddSseRequestHead(sse_type_t ssetype, const std::string& input, bool is_only_c, bool is_copy)
{
std::string ssevalue = input;
switch(ssetype){
case sse_type_t::SSE_DISABLE:
return true;
@ -3135,7 +3136,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd)
return result;
}
int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, std::string& ssevalue)
int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, const std::string& ssevalue)
{
S3FS_PRN_INFO3("[tpath=%s][start=%lld][size=%lld]", SAFESTRPTR(tpath), static_cast<long long>(start), static_cast<long long>(size));

View File

@ -240,7 +240,7 @@ class S3fsCurl
static bool SetIAMRoleFromMetaData(const char* response);
static bool LoadEnvSseCKeys();
static bool LoadEnvSseKmsid();
static bool PushbackSseKeys(std::string& onekey);
static bool PushbackSseKeys(const std::string& onekey);
static bool AddUserAgent(CURL* hCurl);
static int CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
@ -352,18 +352,18 @@ class S3fsCurl
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true);
bool LoadIAMRoleFromMetaData();
bool AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy);
bool AddSseRequestHead(sse_type_t ssetype, const std::string& ssevalue, bool is_only_c, bool is_copy);
bool GetResponseCode(long& responseCode, bool from_curl_handle = true);
int RequestPerform(bool dontAddAuthHeaders=false);
int DeleteRequest(const char* tpath);
bool PreHeadRequest(const char* tpath, const char* bpath = NULL, const char* savedpath = NULL, int ssekey_pos = -1);
bool PreHeadRequest(std::string& tpath, std::string& bpath, std::string& savedpath, int ssekey_pos = -1) {
bool PreHeadRequest(const std::string& tpath, const std::string& bpath, const std::string& savedpath, int ssekey_pos = -1) {
return PreHeadRequest(tpath.c_str(), bpath.c_str(), savedpath.c_str(), ssekey_pos);
}
int HeadRequest(const char* tpath, headers_t& meta);
int PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy);
int PutRequest(const char* tpath, headers_t& meta, int fd);
int PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, std::string& ssevalue);
int PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, const std::string& ssevalue);
int GetObjectRequest(const char* tpath, int fd, off_t start = -1, off_t size = -1);
int CheckBucket();
int ListBucketRequest(const char* tpath, const char* query);

View File

@ -27,8 +27,6 @@
// Functions
//----------------------------------------------
std::string GetContentMD5(int fd);
unsigned char* md5hexsum(int fd, off_t start, ssize_t size);
std::string md5sum(int fd, off_t start, ssize_t size);
struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* data);
struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* key, const char* value);
std::string get_sorted_header_keys(const struct curl_slist* list);

View File

@ -248,7 +248,7 @@ bool takeout_str_dquart(std::string& str)
//
// ex. target="http://......?keyword=value&..."
//
bool get_keyword_value(std::string& target, const char* keyword, std::string& value)
bool get_keyword_value(const std::string& target, const char* keyword, std::string& value)
{
if(!keyword){
return false;

View File

@ -87,7 +87,7 @@ std::string urlEncode2(const std::string &s);
std::string urlDecode(const std::string& s);
bool takeout_str_dquart(std::string& str);
bool get_keyword_value(std::string& target, const char* keyword, std::string& value);
bool get_keyword_value(const std::string& target, const char* keyword, std::string& value);
//
// For binary string