News for hackers. Stuff that matters.
Re:Six times faster than C by gpderetta on Friday July 07, 2023 @06:40AM (#36629761)
You do not even need to subtract 'r'.

    int run_switches(const char* s) {
        int s_count = 0;
        const char *begin = s;
        while(*s) {
            s_count += (1 & *s++);
        }
        int count = s-begin;
        return count - s_count;
    }
which compiles to:

.L49: and edx, 1 add rax, 1 add ecx, edx movzx edx, BYTE PTR [rax] test dl, dl jne .L49

There are no comments on this comment yet.