From 508fafbe627e811688154d5b02a206a473c8a11e Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 17 Jan 2019 22:05:16 -0800 Subject: [PATCH] Remove unnecessary calls to std::string::c_str Found via clang-tidy. --- src/cache.cpp | 10 +++++----- src/curl.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cache.cpp b/src/cache.cpp index 53c5614..7b3b3df 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -231,11 +231,11 @@ bool StatCache::GetStat(string& key, struct stat* pst, headers_t* meta, bool ove stat_cache_t::iterator iter = stat_cache.end(); if(overcheck && '/' != strpath[strpath.length() - 1]){ strpath += "/"; - iter = stat_cache.find(strpath.c_str()); + iter = stat_cache.find(strpath); } if(iter == stat_cache.end()){ strpath = key; - iter = stat_cache.find(strpath.c_str()); + iter = stat_cache.find(strpath); } if(iter != stat_cache.end() && (*iter).second){ @@ -320,11 +320,11 @@ bool StatCache::IsNoObjectCache(string& key, bool overcheck) stat_cache_t::iterator iter = stat_cache.end(); if(overcheck && '/' != strpath[strpath.length() - 1]){ strpath += "/"; - iter = stat_cache.find(strpath.c_str()); + iter = stat_cache.find(strpath); } if(iter == stat_cache.end()){ strpath = key; - iter = stat_cache.find(strpath.c_str()); + iter = stat_cache.find(strpath); } if(iter != stat_cache.end() && (*iter).second) { @@ -582,7 +582,7 @@ bool StatCache::DelStat(const char* key) // If there is "path/" cache, delete it. strpath += "/"; } - if(stat_cache.end() != (iter = stat_cache.find(strpath.c_str()))){ + if(stat_cache.end() != (iter = stat_cache.find(strpath))){ if((*iter).second){ delete (*iter).second; } diff --git a/src/curl.cpp b/src/curl.cpp index 5c6c2ee..cd13346 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -4341,10 +4341,10 @@ string prepare_url(const char* url) uri = url_str.substr(0, uri_length); if(!pathrequeststyle){ - hostname = bucket + "." + url_str.substr(uri_length, bucket_pos - uri_length).c_str(); + hostname = bucket + "." + url_str.substr(uri_length, bucket_pos - uri_length); path = url_str.substr((bucket_pos + bucket_length)); }else{ - hostname = url_str.substr(uri_length, bucket_pos - uri_length).c_str(); + hostname = url_str.substr(uri_length, bucket_pos - uri_length); string part = url_str.substr((bucket_pos + bucket_length)); if('/' != part[0]){ part = "/" + part;