gecko-dev/mozglue
Gerald Squelart 23277409cf Bug 1660177 - Fold GetTotalLength into its only caller CopyDataIntoLazilyAllocatedBuffer - r=canaltinova
Normally I believe it's good to keep functionally-distinct code in separate functions when appropriate.
However in this case, this `ChunkedJSONWriteFunc::GetTotalLength()` function was only used internally, so it's easy to hide it. It is not very big, so it's less important to keep it separate. And its code (going through all chunks to collect sizes) is similar to the code that follows (going through all chunks to collect their content), so it makes some sense to have these similar things in the same place; if one day this chunking change, both loops would probably have to be modified at the same time.

More importantly to justify this change: It was including the final null terminator, which was a bit inconsistent with the usual `Length()` functions in string containers.
Now that code is only used where absolutely necessary (before allocating an output buffer), so it rightly accounts for the null terminator that is added at the end of the contents.

And in upcoming bug 1612799, `ChunkedJSONWriteFunc` will have a new "retired" state (e.g., after an internal memory allocation failed) in which case a public `GetTotalLength()` function could give misleading results -- should it be 0 (nothing to output), 1 (only the null terminator), 5 ("null"), or the length of some error message? So I think it's better not to expose such an ambiguous function.
It could of course be re-introduced if new needs arise in the future.

Differential Revision: https://phabricator.services.mozilla.com/D87833
2020-08-26 08:03:24 +00:00
..
android Bug 689178 - Remove crash-reporter hooks to externally provide library mappings. r=gsvelto 2020-06-25 08:43:23 +00:00
baseprofiler Bug 1660177 - Fold GetTotalLength into its only caller CopyDataIntoLazilyAllocatedBuffer - r=canaltinova 2020-08-26 08:03:24 +00:00
build Bug 1621786 - Fix an incomplete skia suppression. r=mattwoodrow 2020-08-23 09:42:02 +00:00
dllservices Bug 1629002 - unblock asepkcs.dll r=tkikuchi 2020-07-10 22:39:38 +00:00
linker Bug 1519636 - Reformat recent changes to the Google coding style r=andi 2020-07-14 09:34:19 +00:00
misc Backed out 2 changesets (bug 1656526) for build bustages on EarlyBlankWindow.cpp. CLOSED TREE 2020-08-18 19:10:37 +03:00
static
tests Bug 1658230 - Deduplicate ProfileJSONWriter classes - r=gregtatum 2020-08-11 03:50:54 +00:00
moz.build