mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-03 05:00:15 +00:00
Clear containers instead of individual erases
This has O(n) runtime instead of O(n log n).
This commit is contained in:
parent
c04e8e7a9d
commit
4d0bef1e90
@ -213,9 +213,10 @@ void StatCache::Clear()
|
||||
{
|
||||
AutoLock lock(&StatCache::stat_cache_lock);
|
||||
|
||||
for(stat_cache_t::iterator iter = stat_cache.begin(); iter != stat_cache.end(); stat_cache.erase(iter++)){
|
||||
for(stat_cache_t::iterator iter = stat_cache.begin(); iter != stat_cache.end(); ++iter){
|
||||
delete (*iter).second;
|
||||
}
|
||||
stat_cache.clear();
|
||||
S3FS_MALLOCTRIM(0);
|
||||
}
|
||||
|
||||
|
14
src/curl.cpp
14
src/curl.cpp
@ -3958,21 +3958,24 @@ S3fsMultiCurl::~S3fsMultiCurl()
|
||||
bool S3fsMultiCurl::ClearEx(bool is_all)
|
||||
{
|
||||
s3fscurlmap_t::iterator iter;
|
||||
for(iter = cMap_req.begin(); iter != cMap_req.end(); cMap_req.erase(iter++)){
|
||||
for(iter = cMap_req.begin(); iter != cMap_req.end(); ++iter){
|
||||
S3fsCurl* s3fscurl = (*iter).second;
|
||||
if(s3fscurl){
|
||||
s3fscurl->DestroyCurlHandle();
|
||||
delete s3fscurl; // with destroy curl handle.
|
||||
}
|
||||
}
|
||||
cMap_req.clear();
|
||||
|
||||
if(is_all){
|
||||
for(iter = cMap_all.begin(); iter != cMap_all.end(); cMap_all.erase(iter++)){
|
||||
for(iter = cMap_all.begin(); iter != cMap_all.end(); ++iter){
|
||||
S3fsCurl* s3fscurl = (*iter).second;
|
||||
s3fscurl->DestroyCurlHandle();
|
||||
delete s3fscurl;
|
||||
}
|
||||
cMap_all.clear();
|
||||
}
|
||||
|
||||
S3FS_MALLOCTRIM(0);
|
||||
|
||||
return true;
|
||||
@ -4078,7 +4081,7 @@ int S3fsMultiCurl::MultiPerform()
|
||||
|
||||
int S3fsMultiCurl::MultiRead()
|
||||
{
|
||||
for(s3fscurlmap_t::iterator iter = cMap_req.begin(); iter != cMap_req.end(); cMap_req.erase(iter++)) {
|
||||
for(s3fscurlmap_t::iterator iter = cMap_req.begin(); iter != cMap_req.end(); ++iter) {
|
||||
S3fsCurl* s3fscurl = (*iter).second;
|
||||
|
||||
bool isRetry = false;
|
||||
@ -4139,6 +4142,8 @@ int S3fsMultiCurl::MultiRead()
|
||||
}
|
||||
}
|
||||
}
|
||||
cMap_req.clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4155,12 +4160,13 @@ int S3fsMultiCurl::Request()
|
||||
// set curl handle to multi handle
|
||||
int result;
|
||||
s3fscurlmap_t::iterator iter;
|
||||
for(iter = cMap_all.begin(); iter != cMap_all.end(); cMap_all.erase(iter++)){
|
||||
for(iter = cMap_all.begin(); iter != cMap_all.end(); ++iter){
|
||||
CURL* hCurl = (*iter).first;
|
||||
S3fsCurl* s3fscurl = (*iter).second;
|
||||
|
||||
cMap_req[hCurl] = s3fscurl;
|
||||
}
|
||||
cMap_all.clear();
|
||||
|
||||
// Send multi request.
|
||||
if(0 != (result = MultiPerform())){
|
||||
|
@ -2884,9 +2884,10 @@ static int remote_mountpath_exists(const char* path)
|
||||
|
||||
static void free_xattrs(xattrs_t& xattrs)
|
||||
{
|
||||
for(xattrs_t::iterator iter = xattrs.begin(); iter != xattrs.end(); xattrs.erase(iter++)){
|
||||
for(xattrs_t::iterator iter = xattrs.begin(); iter != xattrs.end(); ++iter){
|
||||
delete iter->second;
|
||||
}
|
||||
xattrs.clear();
|
||||
}
|
||||
|
||||
static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTRVAL& pval)
|
||||
|
Loading…
Reference in New Issue
Block a user