I'm appending to a string four bytes a time. Almost everything is 2**19 bytes long or shorter. I'd like to pre-grow my string so perl doesn't have to reallocate it each time I grow the string larger than 2**10 .. 2**18. I can never seem to remember the trick for this so I'm penning it as a SoPW. Help me Obi-wan, you're my only hope.
grow( my( $str ), 2**19 ); while ( ... ) { $str .= pack 'J', ...; # append four bytes at a time. }
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
In reply to Pre-grow a string by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |