… | |
… | |
284 | => "Hello, World!" |
284 | => "Hello, World!" |
285 | |
285 | |
286 | =item $json = $json->shrink ([$enable]) |
286 | =item $json = $json->shrink ([$enable]) |
287 | |
287 | |
288 | Perl usually over-allocates memory a bit when allocating space for |
288 | Perl usually over-allocates memory a bit when allocating space for |
289 | strings. This flag optionally resizes strings generated by either |
289 | strings. This flag optionally resizes strings generated by either |
290 | C<encode> or C<decode> to their minimum size possible. This can save |
290 | C<encode> or C<decode> to their minimum size possible. This can save |
291 | memory when your JSON texts are either very very long or you have many |
291 | memory when your JSON texts are either very very long or you have many |
292 | short strings. It will also try to downgrade any strings to octet-form |
292 | short strings. It will also try to downgrade any strings to octet-form |
293 | if possible: perl stores strings internally either in an encoding called |
293 | if possible: perl stores strings internally either in an encoding called |
294 | UTF-X or in octet-form. The latter cannot store everything but uses less |
294 | UTF-X or in octet-form. The latter cannot store everything but uses less |
295 | space in general. |
295 | space in general (and some buggy Perl or C code might even rely on that |
|
|
296 | internal representation being used). |
296 | |
297 | |
|
|
298 | The actual definition of what shrink does might change in future versions, |
|
|
299 | but it will always try to save space at the expense of time. |
|
|
300 | |
297 | If C<$enable> is true (or missing), the string returned by C<encode> will be shrunk-to-fit, |
301 | If C<$enable> is true (or missing), the string returned by C<encode> will |
298 | while all strings generated by C<decode> will also be shrunk-to-fit. |
302 | be shrunk-to-fit, while all strings generated by C<decode> will also be |
|
|
303 | shrunk-to-fit. |
299 | |
304 | |
300 | If C<$enable> is false, then the normal perl allocation algorithms are used. |
305 | If C<$enable> is false, then the normal perl allocation algorithms are used. |
301 | If you work with your data, then this is likely to be faster. |
306 | If you work with your data, then this is likely to be faster. |
302 | |
307 | |
303 | In the future, this setting might control other things, such as converting |
308 | In the future, this setting might control other things, such as converting |