diff --git a/Source/Engine/Core/Collections/Array.h b/Source/Engine/Core/Collections/Array.h index 40a458ece..7281fa8d8 100644 --- a/Source/Engine/Core/Collections/Array.h +++ b/Source/Engine/Core/Collections/Array.h @@ -579,7 +579,7 @@ public: /// Insert the given item at specified index with keeping items order. /// /// The zero-based index at which item should be inserted. - /// The item to insert. + /// The item to be inserted by copying. void Insert(int32 index, const T& item) { ASSERT(index >= 0 && index <= _count); @@ -592,6 +592,23 @@ public: data[index] = item; } + /// + /// Insert the given item at specified index with keeping items order. + /// + /// The zero-based index at which item should be inserted. + /// The item to inserted by moving. + void Insert(int32 index, T&& item) + { + ASSERT(index >= 0 && index <= _count); + EnsureCapacity(_count + 1); + T* data = _allocation.Get(); + Memory::ConstructItems(data + _count, 1); + for (int32 i = _count - 1; i >= index; i--) + data[i + 1] = MoveTemp(data[i]); + _count++; + data[index] = MoveTemp(item); + } + /// /// Insert the given item at specified index with keeping items order. /// @@ -772,9 +789,9 @@ public: /// /// Performs pop from stack operation (stack grows at the end of the collection). /// - T Pop() + FORCE_INLINE T Pop() { - T item(Last()); + T item = MoveTemp(Last()); RemoveLast(); return item; } @@ -807,6 +824,15 @@ public: Add(item); } + /// + /// Performs enqueue to queue operation (queue head is in the beginning of queue). + /// + /// The item to append. + void Enqueue(T&& item) + { + Add(MoveTemp(item)); + } + /// /// Performs dequeue from queue operation (queue head is in the beginning of queue). /// @@ -814,7 +840,7 @@ public: T Dequeue() { ASSERT(HasItems()); - T item(First()); + T item = MoveTemp(_allocation.Get()[0]); RemoveAtKeepOrder(0); return item; } diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index a30a929de..1cdfccd3b 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -543,6 +543,15 @@ void Actor::SetLayerRecursive(int32 layerIndex) OnLayerChanged(); } +void Actor::SetName(String&& value) +{ + if (_name == value) + return; + _name = MoveTemp(value); + if (GetScene()) + Level::callActorEvent(Level::ActorEventType::OnActorNameChanged, this, nullptr); +} + void Actor::SetName(const StringView& value) { if (_name == value) diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index dc77cdbee..2a2fb1a4c 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -185,7 +185,13 @@ public: /// Sets the actor name. /// /// The value to set. - API_PROPERTY() void SetName(const StringView& value); + API_PROPERTY() void SetName(String&& value); + + /// + /// Sets the actor name. + /// + /// The value to set. + void SetName(const StringView& value); public: ///