summaryrefslogtreecommitdiff
path: root/Source/Core/Common/ChunkFile.h
diff options
context:
space:
mode:
authorash!! <346549+lynlevenick@users.noreply.github.com>2021-04-14 10:29:06 -0700
committerash!! <346549+lynlevenick@users.noreply.github.com>2021-04-18 13:40:42 -0700
commit43ceba4fef168a948cb70fd669229a0f10edeced (patch)
tree15938c7dfdfcbfd2dcec299dda7c3606d861894f /Source/Core/Common/ChunkFile.h
parent14959a1087b05500c5704b59e7d694d941d4a5cf (diff)
optimize TextureCacheBase::SerializeTexture, ::DeserializeTexture
texture serialization and deserialization used to involve many memory allocations and deallocations, along with many copies to and from those allocations. avoid those by reserving a memory region inside the output and writing there directly, skipping the allocation and copy to an intermediate buffer entirely.
Diffstat (limited to 'Source/Core/Common/ChunkFile.h')
-rw-r--r--Source/Core/Common/ChunkFile.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/Core/Common/ChunkFile.h b/Source/Core/Common/ChunkFile.h
index 10f276e595..3e556f5397 100644
--- a/Source/Core/Common/ChunkFile.h
+++ b/Source/Core/Common/ChunkFile.h
@@ -200,6 +200,16 @@ public:
DoArray(arr, static_cast<u32>(N));
}
+ // The caller is required to inspect the mode of this PointerWrap
+ // and deal with the pointer returned from this function themself.
+ [[nodiscard]] u8* DoExternal(u32& count)
+ {
+ Do(count);
+ u8* current = *ptr;
+ *ptr += count;
+ return current;
+ }
+
void Do(Common::Flag& flag)
{
bool s = flag.IsSet();