What's the logic behind freeing the old buffer and re-allocating if the new length exceeds some limit (and why "1250"?)? For huge initial size, it should be insignificant if new content length is 1249 or 1250. In fact, the "1250" can be replaced with "1e8" (or "1e8 minus something small" if that matters) and again Perl re-allocates. I'd expect the opposite behaviour: if new content is the same or almost as big as container, then re-use the container. If it's couple of droplets in huge vessel, then replace the vessel.
use Devel::Peek qw( Dump );
$Devel::Peek::pv_limit =
$Devel::Peek::pv_limit = 10;
my $n;
$_ = "x" x 1e8;
$_ .= "x"; # Force unsharing.
Dump( $_ );
$n = 1249;
$_ = "x" x $n;
Dump( $_ );
$_ = "x" x 1e8;
$_ .= "x"; # Force unsharing.
Dump( $_ );
$n = 1250;
$_ = "x" x $n;
Dump( $_ );
__END__
5.042000
SV = PV(0x21d90461a70) at 0x21d9049cb58
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x21d9dd19060 "xxxxxxxxxx"...\0
CUR = 100000001
LEN = 100000002
SV = PV(0x21d90461a70) at 0x21d9049cb58
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x21d9dd19060 "xxxxxxxxxx"...\0
CUR = 1249
LEN = 100000002
SV = PV(0x21d90461a70) at 0x21d9049cb58
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x21d9dd1e060 "xxxxxxxxxx"...\0
CUR = 100000001
LEN = 100000002
SV = PV(0x21d90461a70) at 0x21d9049cb58
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x21d90497bd0 "xxxxxxxxxx"...\0
CUR = 1250
LEN = 1256