diff options
author | 2019-02-21 22:59:17 +0100 | |
---|---|---|
committer | 2019-02-22 08:18:01 +0100 | |
commit | cf73ccc764d574284bef4ce95ee5bc3e9089f053 (patch) | |
tree | 1655c2836b200c90d5fe5dd5833159e7e8be1522 /src/lib/netlist/plib/pstream.h | |
parent | 6ed352261d40e37887357fe901dc380d6ef79844 (diff) |
netlist: memory management. [Couriersud]
Memory management in plib is now alignment-aware. All allocations
respect c++11 alignas. Selected classes like parray and aligned_vector
also provide hints (__builtin_assume_aligned) to g++ and clang.
The alignment optimizations have little impact on the current use cases.
They only become effective on bigger data processing.
What has a measurable impact is memory pooling. This speeds up netlist
games like breakout and pong by about 5%.
Tested with linux, macosx and windows cross builds. All features are
disabled since I can not rule out they may temporarily break more exotic
builds.
Diffstat (limited to 'src/lib/netlist/plib/pstream.h')
-rw-r--r-- | src/lib/netlist/plib/pstream.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 80619137c51..d5b2bfa4809 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -447,7 +447,7 @@ private: template <typename T> struct constructor_helper { - std::unique_ptr<pistream> operator()(T &&s) { return std::move(plib::make_unique<T>(std::move(s))); } + plib::unique_ptr<pistream> operator()(T &&s) { return std::move(plib::make_unique<T>(std::move(s))); } }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) @@ -489,20 +489,20 @@ public: } private: - std::unique_ptr<pistream> m_strm; + plib::unique_ptr<pistream> m_strm; putf8string m_linebuf; }; template <> struct constructor_helper<putf8_reader> { - std::unique_ptr<pistream> operator()(putf8_reader &&s) { return std::move(s.m_strm); } + plib::unique_ptr<pistream> operator()(putf8_reader &&s) { return std::move(s.m_strm); } }; template <> -struct constructor_helper<std::unique_ptr<pistream>> +struct constructor_helper<plib::unique_ptr<pistream>> { - std::unique_ptr<pistream> operator()(std::unique_ptr<pistream> &&s) { return std::move(s); } + plib::unique_ptr<pistream> operator()(plib::unique_ptr<pistream> &&s) { return std::move(s); } }; @@ -626,11 +626,11 @@ public: { std::size_t sz = 0; read(sz); - auto buf = plib::palloc_array<plib::string_info<pstring>::mem_t>(sz+1); + auto buf = plib::pnew_array<plib::string_info<pstring>::mem_t>(sz+1); m_strm.read(reinterpret_cast<pistream::value_type *>(buf), sz); buf[sz] = 0; s = pstring(buf); - plib::pfree_array(buf); + plib::pdelete_array(buf); } template <typename T> |