pool append move and copy

This commit is contained in:
2026-08-31 08:59:41 +02:00
parent cfb6a9b3dd
commit 4d2470b0c6
4 changed files with 37 additions and 3 deletions
+4
View File
@@ -71,6 +71,7 @@ void Log(LogLevel lvl, std::format_string<Args...> fmt, Args&&... args) {
}
template <typename T>
std::string TypeName() {
#ifdef __RTTI
#if defined(__GNUG__) && !defined(_MSC_VER)
int res = 0;
std::unique_ptr<char, void (*)(void*)> up{
@@ -79,6 +80,9 @@ std::string TypeName() {
#else
return typeid(T).name(); // no demangler available :/
#endif
#else
return "";
#endif
}
} // namespace PD
+25
View File
@@ -107,6 +107,31 @@ class Pool {
pPos = 0;
}
/**
* Copy the data of another pool
*/
void AppendCopy(const Pool& v) {
if (!v.size()) return;
ExpandIf(v.size());
for (size_t i = 0; i < v.size(); i++) {
pData[pPos + i] = v.pData[i];
}
pPos += v.size();
}
/**
* Move the data of another pool
*/
void AppendMove(Pool& v) {
if (!v.size()) return;
ExpandIf(v.size());
for (size_t i = 0; i < v.size(); i++) {
pData[pPos + i] = std::move(v.pData[i]);
}
pPos += v.size();
v.ResetFast();
}
size_t size() const { return pPos; }
size_t capacity() const { return pCap; }
T& at(size_t idx) { return pData[idx]; }
+1 -1
View File
@@ -16,7 +16,7 @@ enum class TextureFormat {
A8,
};
namespace Li {
static int TextureFormat2Bpp(TextureFormat fmt) {
inline int TextureFormat2Bpp(TextureFormat fmt) {
switch (fmt) {
case PD::TextureFormat::A8:
return 1;