[–] trealira 2y ago ↗ Though this is about OCaml, LLVM also does this optimization. From this Reddit post[1], you can see how this gets optimized into an iterative function: size_t my_strlen(const char *s) { return (*s == '\0') ? 0 : 1 + my_strlen(s + 1); } [1]: https://www.reddit.com/r/Compilers/comments/187ng5s/how_does...
1 comment
[ 3.3 ms ] story [ 11.0 ms ] thread