diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 7bf6a63..e2238c4 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1055,8 +1055,8 @@ There are several more performance bugs and gratuitous complication. for (int i = 0; i < strlen(s); ++i) s[i] = tolower(s[i]); } -Yes, this is an example from production code. -We leave it to the reader to figure out what's wasted. +This is actually an example from production code. +We can see that in our condition we have `i < strlen(s)`. This expression will be evaluated on every iteration of the loop, which means that `strlen` must walk through string every loop to discover its length. While the string contents are changing, it's assumed that `toLower` will not affect the length of the string, so it's better to cache the length outside the loop and not incur that cost each iteration. ##### Note diff --git a/scripts/hunspell/isocpp.dic b/scripts/hunspell/isocpp.dic index a333866..29bec28 100644 --- a/scripts/hunspell/isocpp.dic +++ b/scripts/hunspell/isocpp.dic @@ -564,6 +564,7 @@ tmp TMP tock TODO +toLower toolchains TotallyOrdered TP