Closed
Bug 1139993
Opened 9 years ago
Closed 9 years ago
Add VectorBase::ConstRange that only gives out `const T&` entries
Categories
(Core :: MFBT, defect)
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: fitzgen, Assigned: fitzgen)
References
Details
Attachments
(1 file, 1 obsolete file)
2.77 KB,
patch
|
fitzgen
:
review+
|
Details | Diff | Splinter Review |
VectorBase::Range gives out `T&`, but for cases where consumers shouldn't be able to modify entries, only read them, it doesn't provide any nice guarantees. We should have a VectorBase::ConstRange that only gives out `const T&` entries. Is there a better (standard-ish for this type of thing?) name than ConstRange?
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8573439 -
Flags: review?(jwalden+bmo)
Comment 2•9 years ago
|
||
Comment on attachment 8573439 [details] [diff] [review] Add VectorBase::ConstRange that gives out |const T&| entries Review of attachment 8573439 [details] [diff] [review]: ----------------------------------------------------------------- ::: mfbt/Vector.h @@ +492,5 @@ > + { > + MOZ_ASSERT(aCur <= aEnd); > + } > + > + public: Either include ConstRange() {}, or (more likely) remove Range() {} from the class just above. @@ +496,5 @@ > + public: > + bool empty() const { return mCur == mEnd; } > + size_t remain() const { return PointerRangeSize(mCur, mEnd); } > + const T& front() const { MOZ_ASSERT(!empty()); return *mCur; } > + void popFront() { MOZ_ASSERT(!empty()); ++mCur; } Why no popCopyFront? Seems like it should be fine to include, it's not mutating any members, just making copies of them.
Attachment #8573439 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8573439 -
Attachment is obsolete: true
Attachment #8574203 -
Flags: review+
Assignee | ||
Comment 4•9 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f18fa193e90f
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 5•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/9da55484cc2d
Flags: in-testsuite+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9da55484cc2d
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in
before you can comment on or make changes to this bug.
Description
•