mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
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.
This commit is contained in:
parent
99b372a6c5
commit
66fc037ef2
1 changed files with 4 additions and 4 deletions
|
@ -14,10 +14,10 @@
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
namespace {
|
namespace {
|
||||||
template <bool Subsection, typename BlockType, typename BucketType>
|
template <bool Subsection, typename BlockType, typename BucketType>
|
||||||
std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, BlockType block,
|
std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, const BlockType& block,
|
||||||
BucketType buckets) {
|
const BucketType& buckets) {
|
||||||
if constexpr (Subsection) {
|
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) {
|
if (offset >= last_bucket.entries[last_bucket.number_entries].address_patch) {
|
||||||
return {block.number_buckets - 1, last_bucket.number_entries};
|
return {block.number_buckets - 1, last_bucket.number_entries};
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, BlockType bloc
|
||||||
block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets,
|
block.base_offsets.begin() + 1, block.base_offsets.begin() + block.number_buckets,
|
||||||
[&offset](u64 base_offset) { return base_offset <= offset; });
|
[&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) {
|
if (bucket.number_entries == 1) {
|
||||||
return {bucket_id, 0};
|
return {bucket_id, 0};
|
||||||
|
|
Loading…
Reference in a new issue