Closed Bug 327256 Opened 17 years ago Closed 17 years ago
Add ability to ns
COMArray to preallocate space
It'd be nice to have the ability in nsCOMArray to allocate space for a set number of objects. This is useful when inserting a known number of objects since it allows both less error checking and fewer allocations. Patch comming up.
Not sure if the name is great. Other suggestions welcome. I should add that I'm going to add code that uses this function soon, so it's not dead code.
17 years ago
17 years ago
No longer blocks: 325730
Comment on attachment 211957 [details] [diff] [review] Implement EnsureStorageFor I think this should be called SetCapacity to be more consistent with other container classes (e.g., nsString and nsTArray).
Comment on attachment 212024 [details] [diff] [review] Better name Hmm.. looking at strings i'm not sure if the name is ideal as the function is implemented. nsTSubstring::SetCapacity currently sets the capacity to NS_MIN(mLength, aSize) whereas this code sets it to mLength + aSize New patch coming up.
So nsTSubstring::SetCapacity and nsTArray::SetCapacity behave differently. The nsTSubstring one will reduce the length of the string if it can't fit in the new capacity, nsTArray will simply never make the capacity smaller then mLength. I made nsCOMArray behave like nsTArray
It'd be nice to have this on the 1.8 and 1.8.0 branches for bug 271669.
Comment on attachment 212151 [details] [diff] [review] patch v2 a=darin for 1.8.1
Attachment #212151 - Flags: approval-branch-1.8.1+
I just landed this on MOZILLA_1_8_BRANCH and (without approval) MOZILLA_1_8_0_BRANCH so that I could land bug 271669.
This was checked in some time ago
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.