authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-25 14:20:48+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-29 13:33:14+01:00
log78d44e41ef84f9968072914fe288a57e55c683bd
tree3f34fb3182f3bfe9bfc84392a7b85377b0f65a19
parent463fb17320d7320f6f501a266cfd156329ee5cd4
signaturelock-open Commit is signed but in an unrecognized format.

MappedFile: clean up accidental duplicate code


1 files changed, 4 insertions(+), 23 deletions(-)

src/link/MappedFile.zig+4-23
......@@ -1544,25 +1544,6 @@ fn growNodeViaInsertRange(
15441544 // We don't compute the size of the range yet, because depending on `grow_mode` we might want to
15451545 // bump it based on our sibling and parent nodes' alignments. However, we can do an early check
15461546 // for cases where we should obviously exit.
1547 const requested_range_size = new_size - old_size;
1548 if (!mf.flags.block_size.check(requested_range_size)) {
1549 // The requested size isn't exactly aligned.
1550 switch (grow_mode) {
1551 .exact => return false,
1552 .minimum => {
1553 // We can still choose to allow it by increasing the size a bit, but we shouldn't do
1554 // that if it would *significantly* increase the requested size.
1555 const block_size = mf.flags.block_size.toByteUnits();
1556 if (requested_range_size < block_size * 2) {
1557 // Bumping this size up to the next block boundary would be a quite significant
1558 // increase; let's not do it.
1559 return false;
1560 }
1561 },
1562 }
1563 }
1564 // If `grow_mode` is exact, we will use exactly this size, but if it is `.minimum`, we may bump
1565 // the size a little more.
15661547 const min_range_size: u64 = s: {
15671548 const exact_size = new_size - old_size;
15681549 if (mf.flags.block_size.check(exact_size)) {
......@@ -1649,16 +1630,16 @@ fn growNodeViaInsertRange(
16491630 }
16501631 // Traversal done. We didn't hit `max_moved_nodes`, so now we can use the computed alignment
16511632 // requirement to figure out whether we're actually going to insert a range.
1652 if (need_range_align.check(requested_range_size)) {
1653 break :range_size requested_range_size;
1633 if (need_range_align.check(min_range_size)) {
1634 break :range_size min_range_size;
16541635 }
1655 // Perhaps we're allowed to grow by more than `requested_range_size`?
1636 // Perhaps we're allowed to grow by more than `min_range_size`?
16561637 switch (grow_mode) {
16571638 .exact => return false,
16581639 .minimum => {
16591640 const candidate_range_size = need_range_align.forward(min_range_size);
16601641 // Allow growing by up to 50% more than was requested.
1661 if (candidate_range_size <= requested_range_size +| requested_range_size / 2) {
1642 if (candidate_range_size <= min_range_size +| min_range_size / 2) {
16621643 break :range_size candidate_range_size;
16631644 } else {
16641645 return false;