General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
MrAbrazildo
Kantan Coding
comments
Comments by "MrAbrazildo" (@MrAbrazildo) on "Linus's Laws of Writing Readable Code" video.
2:40, these cases should be put in array: 15% faster and the code doesn't grows downside too much. C++ example: const auto Animals = { "dog", "cat", /**/ "last1" }; // All cases. const auto ChosenAnimalPtr = strstr (Animals.data(), tolower (animalType)); // Returns Pointer of the match, not case sensitive. // TODO: check for nonmatch (default case). const auto ChosenAnimalIndex = std::distance (Animals.data(), ChosenAnimalPtr); // That distance from the beginning is the index. ++animalCounts[ChosenAnimalIndex]; 3:53, the previous comments were given a C lesson. I still argue for concise code. So: while (*dest++ = *src++); // Copies string src to dest.
1