From 66fc037ef2181cdddc1588032be18cb368fb3e97 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 15 Sep 2020 09:10:55 -0400 Subject: nca_patch: Significantly reduce the stack usage size within SearchBucketEntry() Previously this function was using ~16KB of stack (16528 bytes), which was caused by the function arguments being taken by value rather than by reference. We can make this significantly lighter on the stack by taking them by reference. --- src/core/file_sys/nca_patch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/file_sys/nca_patch.cpp b/src/core/file_sys/nca_patch.cpp index fd7b69e11..5990a2fd5 100644 --- a/src/core/file_sys/nca_patch.cpp +++ b/src/core/file_sys/nca_patch.cpp @@ -14,10 +14,10 @@ namespace FileSys { namespace { template -std::pair SearchBucketEntry(u64 offset, BlockType block, - BucketType buckets) { +std::pair SearchBucketEntry(u64 offset, const BlockType& block, + const BucketType& buckets) { if constexpr (Subsection) { - const auto last_bucket = buckets[block.number_buckets - 1]; + const auto& last_bucket = buckets[block.number_buckets - 1]; if (offset >= last_bucket.entries[last_bucket.number_entries].address_patch) { return {block.number_buckets - 1, last_bucket.number_entries}; } @@ -29,7 +29,7 @@ std::pair SearchBucketEntry(u64 offset, BlockType bloc block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets, [&offset](u64 base_offset) { return base_offset <= offset; }); - const auto bucket = buckets[bucket_id]; + const auto& bucket = buckets[bucket_id]; if (bucket.number_entries == 1) { return {bucket_id, 0}; -- cgit v1.2.3