]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: use std::count_if() instead 19428/head
authorKefu Chai <kchai@redhat.com>
Tue, 12 Dec 2017 06:07:33 +0000 (14:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 12 Dec 2017 06:31:06 +0000 (14:31 +0800)
and other cleanups

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/erasure-code/lrc/ErasureCodeLrc.cc

index 9a6110bf41c4b716a6fc7cce9e3167634c1955ff..73a0d7e2ab6a85449f375ed99a539f17ee6dba75 100644 (file)
@@ -527,11 +527,7 @@ int ErasureCodeLrc::init(ErasureCodeProfile &profile,
     return ERROR_LRC_MAPPING;
   }
   string mapping = profile.find("mapping")->second;
-  data_chunk_count = 0;
-  for(std::string::iterator it = mapping.begin(); it != mapping.end(); ++it) {
-    if (*it == 'D')
-      data_chunk_count++;
-  }
+  data_chunk_count = count(begin(mapping), end(mapping), 'D');
   chunk_count = mapping.length();
 
   r = layers_sanity_checks(description_string, ss);
@@ -661,8 +657,7 @@ int ErasureCodeLrc::_minimum_to_decode(const set<int> &want_to_read,
               j != erasures.end();
               ++j) {
            erasures_not_recovered.erase(*j);
-           if (erasures_want.count(*j))
-             erasures_want.erase(*j);
+           erasures_want.erase(*j);
          }
        }
       }
@@ -843,8 +838,7 @@ int ErasureCodeLrc::decode_chunks(const set<int> &want_to_read,
           ++c) {
        (*decoded)[*c] = layer_decoded[j];
        ++j;
-       if (erasures.count(*c) != 0)
-         erasures.erase(*c);
+       erasures.erase(*c);
       }
       want_to_read_erasures.clear();
       set_intersection(erasures.begin(), erasures.end(),