Title: [98166] trunk/Websites/webkit.org
- Revision
- 98166
- Author
- [email protected]
- Date
- 2011-10-21 16:18:57 -0700 (Fri, 21 Oct 2011)
Log Message
Style guide should mention the preference of index over iterator
https://bugs.webkit.org/show_bug.cgi?id=70285
Reviewed by Darin Adler.
Per discussion on https://lists.webkit.org/pipermail/webkit-dev/2011-October/018274.html,
we prefer index over iterators.
* coding/coding-style.html:
Modified Paths
Diff
Modified: trunk/Websites/webkit.org/ChangeLog (98165 => 98166)
--- trunk/Websites/webkit.org/ChangeLog 2011-10-21 23:12:31 UTC (rev 98165)
+++ trunk/Websites/webkit.org/ChangeLog 2011-10-21 23:18:57 UTC (rev 98166)
@@ -1,3 +1,15 @@
+2011-10-21 Ryosuke Niwa <[email protected]>
+
+ Style guide should mention the preference of index over iterator
+ https://bugs.webkit.org/show_bug.cgi?id=70285
+
+ Reviewed by Darin Adler.
+
+ Per discussion on https://lists.webkit.org/pipermail/webkit-dev/2011-October/018274.html,
+ we prefer index over iterators.
+
+ * coding/coding-style.html:
+
2011-10-10 Ryosuke Niwa <[email protected]>
Fix a typo pointed by Sam (Weinig).
Modified: trunk/Websites/webkit.org/coding/coding-style.html (98165 => 98166)
--- trunk/Websites/webkit.org/coding/coding-style.html 2011-10-21 23:12:31 UTC (rev 98165)
+++ trunk/Websites/webkit.org/coding/coding-style.html 2011-10-21 23:18:57 UTC (rev 98166)
@@ -708,6 +708,22 @@
MyOtherClass::MyOtherClass() : MySuperClass() {}
</pre>
+
+<li>Prefer index over iterator in Vector iterations for a terse, easier-to-read code.
+
+<h4 class="right">Right:</h4>
+<pre class="code">
+size_t frameViewsCount = frameViews.size();
+for (size_t i = i; i < frameViewsCount; ++i)
+ frameViews[i]->updateLayoutAndStyleIfNeededRecursive();
+</pre>
+
+<h4 class="wrong">Wrong:</h4>
+<pre class="code">
+const Vector<RefPtr<FrameView> >::iterator end = frameViews.end();
+for (Vector<RefPtr<FrameView> >::iterator it = frameViews.begin(); it != end; ++it)
+ (*it)->updateLayoutAndStyleIfNeededRecursive();
+</pre>
</ol>
<h3>Pointers and References</h3>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes