dthain / basekernel

A simple OS kernel for research, teaching, and fun.
GNU General Public License v2.0
805 stars 109 forks source link

Optimization of strchr #257

Closed Broken-Admin closed 3 years ago

Broken-Admin commented 4 years ago

On the below line, in the function strtok, could this while statement not be replaced with a for-loop?

Aforementioned Line

My interpretation of this code into a for-loop -

for (; *s; s++) // Intialize loop
    {
        if (*s == ch) // If *s == ch
        {
            return s; // Return pointer to ch
        }
    }
return 0; // If could not find ch, return 0

With this change implemented, it still makes properly, runs, and has a better overall readability.

dthain commented 4 years ago

Hello - I appreciate the interest in basekernel, but I don't see this as a problem.

Broken-Admin commented 4 years ago

I purely thought it may be possible to improve the readability of the code when replacing the almost obfuscated while-statement.