diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2021-02-07 19:53:34 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2021-02-08 19:15:21 +0000 |
commit | 3acea07c1873b1e4042f4a4fa8668745ee59f15b (patch) | |
tree | 62c91eca4804322136011eedb41761d0a3b5851c /sys/libkern | |
parent | 81e074d57dfcd86f152e2848dc44b77087ee7a2d (diff) | |
download | src-3acea07c1873b1e4042f4a4fa8668745ee59f15b.tar.gz src-3acea07c1873b1e4042f4a4fa8668745ee59f15b.zip |
Restore the augmented strlen commentary
... lost in revert
Diffstat (limited to 'sys/libkern')
-rw-r--r-- | sys/libkern/strlen.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/sys/libkern/strlen.c b/sys/libkern/strlen.c index a8c7964f69a3..1c4a2b954de3 100644 --- a/sys/libkern/strlen.c +++ b/sys/libkern/strlen.c @@ -34,10 +34,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) @@ -45,15 +41,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 */ |