Comment

Comment by derriz

There was a C library - posted here but I cannot remember the name - which used the preprocessor to avoid invoking a function call per comparison. You'd use it something like this:

#define SORT_ELEMENT_TYPE int

#define SORT_COMPARE(a, b) sign(a - b)

#include "specialized_sort.h"

And the header would define a function with the following signature:

int sort_int(int[] a, size_t n);

parent derriz 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton