Skip to content

Commit 3d4811b

Browse files
committed
move and pass by reference for shared pointers
1 parent 29061a1 commit 3d4811b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

redGrapes/SchedulerDescription.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace redGrapes
2929
using Key = TTag;
3030
using ValueType = TScheduler;
3131

32-
SchedulerDescription(std::shared_ptr<TScheduler> scheduler, TTag = DefaultTag{}) : scheduler{scheduler}
32+
SchedulerDescription(std::shared_ptr<TScheduler> const& scheduler, TTag = DefaultTag{}) : scheduler{scheduler}
3333
{
3434
}
3535

redGrapes/redGrapes.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ namespace redGrapes
190190
}
191191

192192
template<typename T>
193-
auto createIOResource(std::shared_ptr<T> o) -> IOResource<T>
193+
auto createIOResource(std::shared_ptr<T> const& o) -> IOResource<T>
194194
{
195195
return IOResource<T>(o);
196196
}

redGrapes/resource/fieldresource.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ namespace redGrapes
288288
static constexpr size_t dim = trait::Field<Container>::dim;
289289

290290
FieldResource(Container* c)
291-
: fieldresource::WriteGuard<Container>(TaskFreeCtx::create_resource_uid(), std::shared_ptr<Container>(c))
291+
: fieldresource::WriteGuard<Container>(TaskFreeCtx::create_resource_uid(), std::make_shared<Container>(c))
292292
{
293293
}
294294

@@ -304,7 +304,7 @@ namespace redGrapes
304304

305305
template<typename U>
306306
FieldResource(FieldResource<U> const& res, Container* c)
307-
: fieldresource::WriteGuard<Container>(res, std::shared_ptr<Container>(c))
307+
: fieldresource::WriteGuard<Container>(res, std::make_shared<Container>(c))
308308
{
309309
}
310310

redGrapes/resource/resource.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace redGrapes
8888
{
8989
AccessBase(boost::typeindex::type_index access_type, std::shared_ptr<ResourceBase> resource)
9090
: access_type(access_type)
91-
, resource(resource)
91+
, resource(std::move(resource))
9292
{
9393
}
9494

@@ -116,7 +116,7 @@ namespace redGrapes
116116
template<typename AccessPolicy>
117117
struct Access : public AccessBase
118118
{
119-
Access(std::shared_ptr<ResourceBase> resource, AccessPolicy policy)
119+
Access(std::shared_ptr<ResourceBase> const& resource, AccessPolicy policy)
120120
: AccessBase(boost::typeindex::type_id<AccessPolicy>(), resource)
121121
, policy(policy)
122122
{
@@ -394,7 +394,7 @@ namespace redGrapes
394394
template<typename T, typename AccessPolicy>
395395
struct SharedResourceObject
396396
{
397-
SharedResourceObject(ResourceId id, std::shared_ptr<T> const& obj) : res{id}, obj(obj)
397+
SharedResourceObject(ResourceId id, std::shared_ptr<T> obj) : res{id}, obj(std::move(obj))
398398
{
399399
}
400400

@@ -405,7 +405,7 @@ namespace redGrapes
405405
{
406406
}
407407

408-
SharedResourceObject(Resource<AccessPolicy> const& res, std::shared_ptr<T> const& obj) : res{res}, obj{obj}
408+
SharedResourceObject(Resource<AccessPolicy> const& res, std::shared_ptr<T> obj) : res{res}, obj{std::move(obj)}
409409
{
410410
}
411411

redGrapes/scheduler/thread_scheduler.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace redGrapes
3333
}
3434

3535
ThreadScheduler(std::shared_ptr<dispatch::thread::WorkerThread<Worker>> workerThread)
36-
: m_worker_thread(workerThread)
36+
: m_worker_thread(std::move(workerThread))
3737
{
3838
}
3939

redGrapes/util/atomic_list.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ namespace redGrapes
289289
* and returns the previous head to which the new_head
290290
* is now linked.
291291
*/
292-
auto append_item(std::shared_ptr<ItemControlBlock> new_head)
292+
auto append_item(std::shared_ptr<ItemControlBlock> const& new_head)
293293
{
294294
TRACE_EVENT("Allocator", "AtomicList::append_item()");
295295
std::shared_ptr<ItemControlBlock> old_head;
@@ -306,7 +306,7 @@ namespace redGrapes
306306
}
307307

308308
// append the first head item if not already exists
309-
bool try_append_first_item(std::shared_ptr<ItemControlBlock> new_head)
309+
bool try_append_first_item(std::shared_ptr<ItemControlBlock> const& new_head)
310310
{
311311
TRACE_EVENT("Allocator", "AtomicList::append_first_item()");
312312

0 commit comments

Comments
 (0)