Hacker News new | ask | show | jobs
by cv5005 547 days ago
Or it could be made faster because certain manual optimizations become possible.

An example would a table of interned strings that you wanna match against (say you're writing a parser). Since standard C says thou shall not compare pointers with < or > unless they both point into the same 'object' you are forbidden from doing the speed of light code:

  char *keywords_begin, *keywords_end;
  if(some_str >= keywords_begin && some_str < keywords_end) ...
Official standard sanctioned workarounds would require extra indirection (using indices for example) which is suboptimal.
1 comments

You can cast them to uintptr_t and compare them to your heart's desire.