@@ -23,11 +23,8 @@ namespace sd
23
23
24
24
template <class TValue > const TValue *GetValueAs () const
25
25
{
26
- if (auto casted = Upcast<TValue>())
27
- {
28
- return casted->GetValue ();
29
- }
30
- return nullptr ;
26
+ auto casted = Upcast<TValue>();
27
+ return casted ? casted->GetValue () : nullptr ;
31
28
}
32
29
33
30
virtual ~CacheItemBase (){};
@@ -47,7 +44,7 @@ namespace sd
47
44
return Ptr (new CacheItem<TValue>(key, std::move (value)));
48
45
}
49
46
50
- CacheItem (const std::string &key, TValue &&value) : _key(key), _value(value) {}
47
+ CacheItem (const std::string &key, TValue &&value) : _key(key), _value(std::move( value) ) {}
51
48
52
49
const std::string &GetKey () const final { return _key; }
53
50
const void *GetRawValue () const final { return GetValue (); }
@@ -110,9 +107,9 @@ namespace sd
110
107
111
108
struct ICache
112
109
{
113
- virtual bool Add (CacheItemBase::Ptr itemPtr , ICachePolicy::Ptr policy = nullptr ) = 0;
110
+ virtual bool Add (CacheItemBase::Ptr item , ICachePolicy::Ptr policy = nullptr ) = 0;
114
111
115
- virtual bool Set (CacheItemBase::Ptr itemPtr , ICachePolicy::Ptr policy = nullptr ) = 0;
112
+ virtual bool Set (CacheItemBase::Ptr item , ICachePolicy::Ptr policy = nullptr ) = 0;
116
113
117
114
virtual const void *Get (const std::string &key) const = 0;
118
115
@@ -153,13 +150,13 @@ namespace sd
153
150
}
154
151
155
152
template <class TValue >
156
- bool Add (typename CacheItem<TValue>::Ptr itemPtr , typename CachePolicy<TValue>::Ptr policy = nullptr )
153
+ bool Add (typename CacheItem<TValue>::Ptr item , typename CachePolicy<TValue>::Ptr policy = nullptr )
157
154
{
158
- CacheItemBase::Ptr itemPtrCasted = std::move (itemPtr );
159
- return Add (std::move (itemPtrCasted ), std::move (policy));
155
+ CacheItemBase::Ptr itemCasted = std::move (item );
156
+ return Add (std::move (itemCasted ), std::move (policy));
160
157
}
161
158
162
- bool Add (CacheItemBase::Ptr itemPtr , ICachePolicy::Ptr policy = nullptr ) final ;
159
+ bool Add (CacheItemBase::Ptr item , ICachePolicy::Ptr policy = nullptr ) final ;
163
160
164
161
template <class TValue >
165
162
bool Set (const std::string &key, TValue &&value, typename CachePolicy<TValue>::Ptr policy = nullptr )
@@ -168,13 +165,13 @@ namespace sd
168
165
}
169
166
170
167
template <class TValue >
171
- bool Set (typename CacheItem<TValue>::Ptr itemPtr , typename CachePolicy<TValue>::Ptr policy = nullptr )
168
+ bool Set (typename CacheItem<TValue>::Ptr item , typename CachePolicy<TValue>::Ptr policy = nullptr )
172
169
{
173
- CacheItemBase::Ptr itemPtrCasted = std::move (itemPtr );
174
- return Set (std::move (itemPtrCasted ), std::move (policy));
170
+ CacheItemBase::Ptr itemCasted = std::move (item );
171
+ return Set (std::move (itemCasted ), std::move (policy));
175
172
}
176
173
177
- bool Set (CacheItemBase::Ptr itemPtr , ICachePolicy::Ptr policy = nullptr ) final ;
174
+ bool Set (CacheItemBase::Ptr item , ICachePolicy::Ptr policy = nullptr ) final ;
178
175
179
176
template <class TValue > const TValue *Get (const std::string &key) const
180
177
{
0 commit comments