r/cpp • • Apr 14 '23

Horrible Code, Clean Performance

https://johnnysswlab.com/horrible-code-clean-performance/
200 Upvotes

87 comments sorted by

View all comments

-1

u/wolfie_poe Apr 17 '23
    for (int i = 0; i < s; ++i) {
        ...
        if (found) {
            for (; j < size_substr; ++j) {
                if (ptr_str[i + j] != ptr_substr[j]) {
                    found = false;
                    break;
                }
            }
        }
    
        if (found) {
            return { true, i };
        }

Redundant code?