-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Currently the NewDocument function takes a uint which is used as the initial capacity for the slices of the *Document. This was done primarily to enable users to allocate a single array upfront and then append to it later.
Instead of doing it that way, update NewDocument to take a variadic list of *Elements. If a user wishes to control allocations, they can first make a []*Element, fill it with documents, and then pass that to NewDocument. In NewDocument we'll reuse the provided slice to ensure we don't allocate an extra array.
For the majority of use cases, this change will enable a more concise creation of documents.