From dda7a868b1d6b20e35dfd24abe2c4949e13e3fc3 Mon Sep 17 00:00:00 2001 From: Eliyahu Ravuna Date: Fri, 20 Nov 2015 03:31:37 +0200 Subject: [PATCH] Suggested example for PER.4 --- CppCoreGuidelines.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 7817d73..a7e8576 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -9116,6 +9116,27 @@ If your program spends most of its time waiting for the web or for a human, opti Simple code can be very fast. Optimizers sometimes do marvels with simple code +##### Example, good + + // clear expression of intent, fast execution + + vector v(100000); + + for(auto& c : v) + c = ~c; + +##### Example, bad + + // intended to be faster, but is actually slower + + vector v(100000); + + for(size_t i=0; i(&v[i]); + quad_word = ~quad_word; + } + ##### Note ???