From 0a1fa15ab5d4b21066a738aba4b03bca6302967e Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 21 Apr 2016 15:51:41 +0800 Subject: [PATCH] crush: remove unnecessary sanity check We have done sanity check with bucket_exists() above, so these checks are redundant and less effcient. Signed-off-by: xie xingguo --- src/crush/CrushWrapper.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 16f61dfb7467..490c79fc97a1 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -645,8 +645,8 @@ int CrushWrapper::insert_item(CephContext *cct, int item, float weight, string n return -EINVAL; } + // we have done sanity check above crush_bucket *b = get_bucket(id); - assert(b); if (p->first != b->type) { ldout(cct, 1) << "insert_item existing bucket has type " @@ -808,8 +808,6 @@ int CrushWrapper::get_item_weight_in_loc(int id, const map &loc) if (!bucket_exists(bid)) continue; crush_bucket *b = get_bucket(bid); - if ( b == NULL) - continue; for (unsigned int i = 0; i < b->size; i++) { if (b->items[i] == id) { return crush_get_bucket_item_weight(b, i); @@ -851,8 +849,6 @@ int CrushWrapper::adjust_item_weight_in_loc(CephContext *cct, int id, int weight if (!bucket_exists(bid)) continue; crush_bucket *b = get_bucket(bid); - if ( b == NULL) - continue; for (unsigned int i = 0; i < b->size; i++) { if (b->items[i] == id) { int diff = crush_bucket_adjust_item_weight(crush, b, id, weight); -- 2.47.3