Closed
Bug 1081606
Opened 9 years ago
Closed 9 years ago
Don't call toArray with a zero-length array.
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 35
People
(Reporter: ckitching, Assigned: ckitching)
Details
Attachments
(1 file)
5.14 KB,
patch
|
rnewman
:
review+
|
Details | Diff | Splinter Review |
Collections provide a toArray method which spits out an array of the same type as the one you pass it. If the array you pass it is large enough to hold the contents of the collection, your output goes in there. If not, the library uses Reflection to create a new array of the required type and size, and returns that. This is, unsurprisingly, painfully slow. You can always create an array of precisely the right size using Collection.size(), so just do that. (If you're thinking that doing this on a LinkedList is not okay because size() is linear... it's not. The LinkedList implementation keeps a "size" variable internally and keeps count as you add/remove elements, so it's constant-time to do size()).
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8503710 -
Flags: review?(rnewman)
Comment 2•9 years ago
|
||
Comment on attachment 8503710 [details] [diff] [review] Don't call toArray with zero-size arrays Review of attachment 8503710 [details] [diff] [review]: ----------------------------------------------------------------- Yay perf. Upstream needed.
Attachment #8503710 -
Flags: review?(rnewman) → review+
Assignee | ||
Comment 3•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/8bb3624363e5
Comment 4•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/8bb3624363e5
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
Updated•2 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•