1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-28 14:00:31 +02:00

Optimize R6RS bitwise operators.

* module/rnrs/arithmetic/bitwise.scm (bitwise-if, bitwise-length,
  bitwise-first-bit-set, bitwise-bit-field, bitwise-reverse-bit-field):
  Replace these with aliases to the identical SRFI-60 operators
  'bitwise-if', 'integer-length', 'first-set-bit', 'bit-field', and
  'reverse-bit-field'.

  (bitwise-copy-bit, bitwise-copy-bit-field, bitwise-rotate-bit-field):
  Reimplement these based upon the similar SRFI-60 operators 'copy-bit',
  'copy-bit-field', and 'rotate-bit-field'.

* test-suite/tests/r6rs-arithmetic-bitwise.test (bitwise-copy-bit): Fix
  test to conform to the specification, which requires the third
  argument to be either 0 or 1.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fxcopy-bit): Fix test
  to conform to the specification, which requires the third argument to
  be either 0 or 1.
This commit is contained in:
Mark H Weaver 2013-07-21 10:00:48 -04:00
parent eba5c07715
commit 93da406f33
3 changed files with 24 additions and 61 deletions

View file

@ -62,7 +62,7 @@
(with-test-prefix "bitwise-copy-bit"
(pass-if "bitwise-copy-bit simple"
(eqv? (bitwise-copy-bit #b010 2 #b111) #b110)))
(eqv? (bitwise-copy-bit #b010 2 1) #b110)))
(with-test-prefix "bitwise-bit-field"
(pass-if "bitwise-bit-field simple"

View file

@ -184,7 +184,7 @@
(pass-if "fxbit-set? is #f on index of unset bit" (not (fxbit-set? 5 1))))
(with-test-prefix "fxcopy-bit" (pass-if "simple" (fx=? (fxcopy-bit 2 2 7) 6)))
(with-test-prefix "fxcopy-bit" (pass-if "simple" (fx=? (fxcopy-bit 2 2 1) 6)))
(with-test-prefix "fxbit-field"
(pass-if "simple" (fx=? (fxbit-field 50 1 4) 1)))