diff --git a/lib/main/containers/pideque.h b/lib/main/containers/pideque.h index 945a1227..770c123e 100644 --- a/lib/main/containers/pideque.h +++ b/lib/main/containers/pideque.h @@ -278,7 +278,7 @@ public: memmove((void*)(&(pid_data[pid_start])), (const void*)(&(pid_data[pid_start + 1])), index * sizeof(T)); } PIINTROSPECTION_CONTAINER_USED(T, 1) - elementNew(pid_data + pid_start + index, v); + elementNew(pid_data + pid_start + index, std::move(v)); return *this; } inline PIDeque & insert(size_t index, const PIDeque & other) { @@ -370,11 +370,11 @@ public: inline PIDeque & push_back(T && v) { alloc(pid_size + 1, true); PIINTROSPECTION_CONTAINER_USED(T, 1); - elementNew(pid_data + pid_start + pid_size - 1, v); + elementNew(pid_data + pid_start + pid_size - 1, std::move(v)); return *this; } inline PIDeque & append(const T & v) {return push_back(v);} - inline PIDeque & append(T && v) {return push_back(v);} + inline PIDeque & append(T && v) {return push_back(std::move(v));} inline PIDeque & append(const PIDeque & t) { assert(&t != this); size_t ps = pid_size; @@ -383,7 +383,7 @@ public: return *this; } inline PIDeque & operator <<(const T & v) {return push_back(v);} - inline PIDeque & operator <<(T && v) {return push_back(v);} + inline PIDeque & operator <<(T && v) {return push_back(std::move(v));} inline PIDeque & operator <<(const PIDeque & t) {return append(t);} inline PIDeque & push_front(const T & v) {insert(0, v); return *this;} @@ -451,7 +451,7 @@ private: } } inline void elementNew(T * to, const T & from) {new(to)T(from);} - inline void elementNew(T * to, T && from) {piSwap(*to, from);} + inline void elementNew(T * to, T && from) {new(to)T(std::move(from));} inline void elementDelete(T & from) {from.~T();} inline void dealloc() { if ((uchar*)pid_data != 0) free((uchar*)pid_data); diff --git a/lib/main/containers/pivector.h b/lib/main/containers/pivector.h index df2987be..7b3e3982 100644 --- a/lib/main/containers/pivector.h +++ b/lib/main/containers/pivector.h @@ -268,7 +268,7 @@ public: memmove((void*)(&(piv_data[index + 1])), (const void*)(&(piv_data[index])), os * sizeof(T)); } PIINTROSPECTION_CONTAINER_USED(T, 1) - elementNew(piv_data + index, v); + elementNew(piv_data + index, std::move(v)); return *this; } inline PIVector & insert(size_t index, const PIVector & other) { @@ -346,11 +346,11 @@ public: inline PIVector & push_back(T && v) { alloc(piv_size + 1); PIINTROSPECTION_CONTAINER_USED(T, 1); - elementNew(piv_data + piv_size - 1, v); + elementNew(piv_data + piv_size - 1, std::move(v)); return *this; } inline PIVector & append(const T & v) {return push_back(v);} - inline PIVector & append(T && v) {return push_back(v);} + inline PIVector & append(T && v) {return push_back(std::move(v));} inline PIVector & append(const PIVector & other) { assert(&other != this); size_t ps = piv_size; @@ -359,7 +359,7 @@ public: return *this; } inline PIVector & operator <<(const T & v) {return push_back(v);} - inline PIVector & operator <<(T && v) {return push_back(v);} + inline PIVector & operator <<(T && v) {return push_back(std::move(v));} inline PIVector & operator <<(const PIVector & other) {return append(other);} inline PIVector & push_front(const T & v) {insert(0, v); return *this;} @@ -436,7 +436,7 @@ private: } } inline void elementNew(T * to, const T & from) {new(to)T(from);} - inline void elementNew(T * to, T && from) {piSwap(*to, from);} + inline void elementNew(T * to, T && from) {new(to)T(std::move(from));} inline void elementDelete(T & from) {from.~T();} inline void dealloc() { if ((uchar*)piv_data != 0) free((uchar*)piv_data); diff --git a/main.cpp b/main.cpp index cbcedb6b..7832f59b 100644 --- a/main.cpp +++ b/main.cpp @@ -34,22 +34,18 @@ int main() { #include "picodeparser.h" int main() { - //piDebug = false; + piDebug = false; double min = -1, max = -1, mean = 0; - for (int i = 0; i < 1; ++i) { + for (int i = 0; i < 50; ++i) { PITimeMeasurer tm; /*PICodeParser cp; cp.parseFile("SH_plugin_base.h");*/ PIStringList sl; - sl.reserve(10); - for (int i = 0; i < 10; ++i) { - //PIString s = PIString("1234567890-=").repeated(100); - //sl.push_back(PIString("1234567890-=").repeated(100)); - sl << PIString("abc").repeated(i + 1); - } - for (PIString & s : sl) { - s = s.toUpperCase(); - piCout << s; + sl.reserve(50000); + for (int i = 0; i < 50000; ++i) { +// PIString s("1234567890-="); + sl.push_back(PIString("1234567890-=")); + //sl << PIString("1234567890-="); } double ms = tm.elapsed_m(); if (min < 0) min = ms;