Closed Bug 517943 Opened 15 years ago Closed 15 years ago

Need a way to append the contents of an nsTArray to another without copying

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

.Append() on nsTArray copy constucts. The HTML5 parser needs a method that moves stuff over from another nsTArray and empties the other array withou running constructors/destructors. (In order to move around tree operations without leaking or prematurely deleting members that aren't refcounted but deleted when the tree op goes away.)
Blocks: 516406
Attachment #402066 - Flags: review?(benjamin)
Attachment #402066 - Flags: superreview?(dbaron)
Comment on attachment 402066 [details] [diff] [review]
Add MoveElementsFrom to nsTArray

No other parts of nsTArray will assign from another array without copy construction: this seems like an unfortunate design decision.
SwapElements() kind of assigns from another array without copy construction.
Summary: Need a way to append the contents of an nsTArray to another withou copying → Need a way to append the contents of an nsTArray to another without copying
Attachment #402066 - Flags: superreview?(dbaron) → superreview+
Comment on attachment 402066 [details] [diff] [review]
Add MoveElementsFrom to nsTArray

sr=dbaron (assuming bsmedberg's review+), if you stick an NS_PRECONDITION(&array != this, "argument must be different array"); (or better assertion text) at the beginning
Attachment #402066 - Flags: review?(benjamin) → review+
Comment on attachment 402066 [details] [diff] [review]
Add MoveElementsFrom to nsTArray

Please make the comment

"Move all elements from another array to the end of this array without calling copy constructors or destructors."
Thank you for the reviews.

Pushed with the changes suggested:
http://hg.mozilla.org/mozilla-central/rev/f2a06414948c
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: