diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-10-11 17:21:21 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-10-11 17:21:21 -0700 |
commit | 0f73f0acaf87b73c932d4b2bad1f981503554f63 (patch) | |
tree | cc529dc7dd7c5ad18aca164f524cec3081c98eb1 | |
parent | 8aa7f65f4b1c74454767c805b232a7d732378c1a (diff) | |
download | ceph-0f73f0acaf87b73c932d4b2bad1f981503554f63.tar.gz |
rgw: switch out param to a pointer instead of reference
following code review
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/common/lru_map.h | 13 | ||||
-rw-r--r-- | src/rgw/rgw_quota.cc | 14 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/common/lru_map.h b/src/common/lru_map.h index 98fb44a932e..1e1acc95f76 100644 --- a/src/common/lru_map.h +++ b/src/common/lru_map.h @@ -24,7 +24,9 @@ public: class UpdateContext { public: virtual ~UpdateContext() {} - virtual bool update(V& v) = 0; + + /* update should return true if object is updated */ + virtual bool update(V *v) = 0; }; bool _find(const K& key, V *value, UpdateContext *ctx); @@ -35,6 +37,13 @@ public: virtual ~lru_map() {} bool find(const K& key, V& value); + + /* + * find_and_update() + * + * - will return true if object is found + * - if ctx is set will return true if object is found and updated + */ bool find_and_update(const K& key, V *value, UpdateContext *ctx); void add(const K& key, V& value); void erase(const K& key); @@ -54,7 +63,7 @@ bool lru_map<K, V>::_find(const K& key, V *value, UpdateContext *ctx) bool r = true; if (ctx) - r = ctx->update(e.value); + r = ctx->update(&e.value); if (value) *value = e.value; diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index e6970c5e0a6..66609ca723c 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -164,11 +164,11 @@ class RGWBucketStatsAsyncTestSet : public lru_map<rgw_bucket, RGWQuotaBucketStat uint64_t removed_bytes; public: RGWBucketStatsAsyncTestSet() {} - bool update(RGWQuotaBucketStats& entry) { - if (entry.async_refresh_time.sec() == 0) + bool update(RGWQuotaBucketStats *entry) { + if (entry->async_refresh_time.sec() == 0) return false; - entry.async_refresh_time = utime_t(0, 0); + entry->async_refresh_time = utime_t(0, 0); return true; } @@ -257,13 +257,13 @@ class RGWBucketStatsUpdate : public lru_map<rgw_bucket, RGWQuotaBucketStats>::Up public: RGWBucketStatsUpdate(int _objs_delta, uint64_t _added_bytes, uint64_t _removed_bytes) : objs_delta(_objs_delta), added_bytes(_added_bytes), removed_bytes(_removed_bytes) {} - bool update(RGWQuotaBucketStats& entry) { + bool update(RGWQuotaBucketStats *entry) { uint64_t rounded_kb_added = rgw_rounded_kb(added_bytes); uint64_t rounded_kb_removed = rgw_rounded_kb(removed_bytes); - entry.stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed); - entry.stats.num_kb += (added_bytes - removed_bytes) / 1024; - entry.stats.num_objects += objs_delta; + entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed); + entry->stats.num_kb += (added_bytes - removed_bytes) / 1024; + entry->stats.num_objects += objs_delta; return true; } |