From efdf0e01a9700f5536999eef32d01e02fbf72c14 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Tue, 31 May 2016 15:27:48 -0700 Subject: [PATCH] Avoid copying `List` unnecessarily. --- src/js_list.hpp | 6 +++--- src/js_object_accessor.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js_list.hpp b/src/js_list.hpp index d936159c..52fe358c 100644 --- a/src/js_list.hpp +++ b/src/js_list.hpp @@ -41,7 +41,7 @@ struct ListClass : ClassDefinition> { using Value = js::Value; using ReturnValue = js::ReturnValue; - static ObjectType create_instance(ContextType, realm::List &); + static ObjectType create_instance(ContextType, realm::List); // properties static void get_length(ContextType, ObjectType, ReturnValue &); @@ -81,8 +81,8 @@ struct ListClass : ClassDefinition> { }; template -typename T::Object ListClass::create_instance(ContextType ctx, realm::List &list) { - return create_object>(ctx, new realm::List(list)); +typename T::Object ListClass::create_instance(ContextType ctx, realm::List list) { + return create_object>(ctx, new realm::List(std::move(list))); } template diff --git a/src/js_object_accessor.hpp b/src/js_object_accessor.hpp index 4809f23a..dead643e 100644 --- a/src/js_object_accessor.hpp +++ b/src/js_object_accessor.hpp @@ -135,7 +135,7 @@ struct NativeAccessor { return Object::validated_get_object(ctx, Value::validated_to_object(ctx, value), (uint32_t)index); } static ValueType from_list(ContextType ctx, realm::List list) { - return ListClass::create_instance(ctx, list); + return ListClass::create_instance(ctx, std::move(list)); } static Mixed to_mixed(ContextType ctx, ValueType &val) {