aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-02-07 19:53:34 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-02-08 19:15:21 +0000
commit3acea07c1873b1e4042f4a4fa8668745ee59f15b (patch)
tree62c91eca4804322136011eedb41761d0a3b5851c /lib/libc
parent81e074d57dfcd86f152e2848dc44b77087ee7a2d (diff)
downloadsrc-3acea07c1873b1e4042f4a4fa8668745ee59f15b.tar.gz
src-3acea07c1873b1e4042f4a4fa8668745ee59f15b.zip
Restore the augmented strlen commentary
... lost in revert
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/string/strlen.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c
index a862ffc245ca..2d1803b1e078 100644
--- a/lib/libc/string/strlen.c
+++ b/lib/libc/string/strlen.c
@@ -35,10 +35,6 @@ __FBSDID("$FreeBSD$");
/*
* Portable strlen() for 32-bit and 64-bit systems.
*
- * Rationale: it is generally much more efficient to do word length
- * operations and avoid branches on modern computer systems, as
- * compared to byte-length operations with a lot of branches.
- *
* The expression:
*
* ((x - 0x01....01) & ~x & 0x80....80)
@@ -46,15 +42,12 @@ __FBSDID("$FreeBSD$");
* would evaluate to a non-zero value iff any of the bytes in the
* original word is zero.
*
- * On multi-issue processors, we can divide the above expression into:
- * a) (x - 0x01....01)
- * b) (~x & 0x80....80)
- * c) a & b
- *
- * Where, a) and b) can be partially computed in parallel.
- *
* The algorithm above is found on "Hacker's Delight" by
* Henry S. Warren, Jr.
+ *
+ * Note: this leaves performance on the table and each architecture
+ * would be best served with a tailor made routine instead, even if
+ * using the same trick.
*/
/* Magic numbers for the algorithm */