1. A method comprising: providing a non-active representation of a document, the non-active representation of the document comprising a piece descriptor and a piece descriptor index; executing, by a computing system, a builder thread to input or modify an element in the document, the builder thread creating a new piece descriptor for indicating a position where the element belongs in the document, the new piece descriptor and the piece descriptor index forming an active representation of the document, wherein the active representation of the document and the non-active representation of the document refer to the same data stored in memory; providing access to the non-active representation for use by a reader thread while the builder thread modifies the active representation of the document; after the builder thread modifies the document, updating the non-active representation of the document with the active representation of the document, such that modifications to the element at the position indicated by the new piece descriptor replaces a corresponding element at the position indicated by the piece descriptor in the non-active representation of the document; and after updating the non-active representation, providing access to the non-active representation of the document including the modifications to the element.
1. A method comprising: providing a non-active representation of a document, the non-active representation of the document comprising a piece descriptor and a piece descriptor index; executing, by a computing system, a builder thread to input or modify an element in the document, the builder thread creating a new piece descriptor for indicating a position where the element belongs in the document, the new piece descriptor and the piece descriptor index forming an active representation of the document, wherein the active representation of the document and the non-active representation of the document refer to the same data stored in memory; providing access to the non-active representation for use by a reader thread while the builder thread modifies the active representation of the document; after the builder thread modifies the document, updating the non-active representation of the document with the active representation of the document, such that modifications to the element at the position indicated by the new piece descriptor replaces a corresponding element at the position indicated by the piece descriptor in the non-active representation of the document; and after updating the non-active representation, providing access to the non-active representation of the document including the modifications to the element. 7. The method of claim 1 , wherein the document is internally represented as a document tree, the document tree being a hierarchy of document elements; wherein the active representation of the document includes a real element array that contains elements that represent each document element in the document tree; wherein the non-active representation of the document includes the real element array; wherein the active representation of the document and the non-active representation of the document do not include different copies in the memory of the same elements in the real element array.