Implement assume()
authorGiuseppe Ottaviano <ott@fb.com>
Tue, 8 Sep 2015 19:20:36 +0000 (12:20 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Tue, 8 Sep 2015 20:20:17 +0000 (13:20 -0700)
commitb6a637141cf0d28ccdda5a9eccbe57ba5f367c67
tree65d5ecf542ebb602d71b3f3710f31c0d1c95b892
parent37cd970a9dfd98d75baed229a922d138a2bf0b03
Implement assume()

Summary: In some cases hinting the compiler about conditions that are guaranteed
to be true can help it generate better code. For instance, remove
unnecessary bound checks. Clang has `__builtin_assume` and on GCC we
can simulate it with `__builtin_unreachable`, so better just abstract
both into a function.

Reviewed By: @philippv

Differential Revision: D2419937
folly/Assume.h [new file with mode: 0644]
folly/Makefile.am
folly/Portability.h