This is an archive of the discontinued LLVM Phabricator instance.

[docs] Add a note on iteration of unordered containers to coding standards
ClosedPublic

Authored by mgrang on Sep 6 2017, 11:55 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

mgrang created this revision.Sep 6 2017, 11:55 AM
mgrang updated this revision to Diff 114047.Sep 6 2017, 12:31 PM
mgrang edited the summary of this revision. (Show Details)

Made changes in the text based on comments:

@dblaikie: "Might be worth pivoting this a bit differently to talk about ordering of pointers if that's the specific niche we're going to discourage/outlaw. (this could happen on std::set/map/etc too, when used with pointer keys)

Also "sort before iteration" is a bit too strong since it's only about when iterating to produce an ordered result (if it's an iteration to compute, say, a total or some order-agnostic summary/result, that's fine)."

docs/CodingStandards.rst
814 ↗(On Diff #114047)

Thanks for the suggestions @dblaikie. How does this sound?

mgrang updated this revision to Diff 114049.Sep 6 2017, 12:34 PM
dblaikie accepted this revision.Sep 6 2017, 1:02 PM

Sure, good enough for me.

I'd probably drop "iteration" from the title (maybe "Beware of non-determinism due to ordering of pointers" ?).

& maybe in the last sentence "like vector/MapVector/SetVector".

This revision is now accepted and ready to land.Sep 6 2017, 1:02 PM
mgrang updated this revision to Diff 114057.Sep 6 2017, 1:12 PM

Addressed comments.

This revision was automatically updated to reflect the committed changes.