Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on In C++, is empty() faster than comparing the size with zero?.
size_t count_nodes(const node* p) { size_t size = 0; while (p) { p = p->next; size++; if(size == 1000) return 1000; } return size; }
Interestingly, this version is optimized by GCC and Clang:
size_t count_nodes(const node* p) { size_t size = 0; while (p && (size < 1000)) { p = p->next; size++; } return size; }
There are no comments on this comment yet.
Interestingly, this version is optimized by GCC and Clang:
https://godbolt.org/z/YKWbWb5zr