Open Bug 1297805 Opened 9 years ago Updated 3 years ago

avoid array bounds checking in nsTArray methods

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

People

(Reporter: froydnj, Unassigned)

Details

Attachments

(1 file)

There are a few places in nsTArray where we know exactly how many elements we're operating on, so we can avoid the bounds-checked operator[] methods and use direct pointer accesses instead, which saves space and time.avoid array bounds checking in nsTArray methods; r=erahm
Comment on attachment 8784524 [details] [diff] [review] avoid array bounds checking in nsTArray methods Review of attachment 8784524 [details] [diff] [review]: ----------------------------------------------------------------- ::: xpcom/glue/nsTArray.h @@ +2097,5 @@ > const char* aName, > uint32_t aFlags = 0) > { > aFlags |= CycleCollectionEdgeNameArrayFlag; > size_t length = aField.Length(); You can get rid of |length|.
Attachment #8784524 - Flags: review?(erahm) → review+
Comment on attachment 8784524 [details] [diff] [review] avoid array bounds checking in nsTArray methods Review of attachment 8784524 [details] [diff] [review]: ----------------------------------------------------------------- Hey Nathan, found this old review hanging around. Do you still want to land it? ::: xpcom/glue/nsTArray.h @@ +2099,5 @@ > { > aFlags |= CycleCollectionEdgeNameArrayFlag; > size_t length = aField.Length(); > + for (auto& elem : aField) { > + ImplCycleCollectionTraverse(aCallback, elem, aName, aFlags); Our iterator does bounds checking now, so this isn't really a win in this form.
Flags: needinfo?(nfroyd)
Landing it would probably be good. Do you have any objection to me making the obvious Elements()-related change to the cycle collection hook, since our iterators bounds-check now?
Flags: needinfo?(nfroyd)
(In reply to Nathan Froyd [:froydnj] from comment #4) > Landing it would probably be good. Do you have any objection to me making > the obvious Elements()-related change to the cycle collection hook, since > our iterators bounds-check now? r=me
Priority: -- → P3

The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.

Assignee: froydnj+bz → nobody

Patch still looks relevant FWIW.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: