TaylanUB / scheme-bytestructures

Structured access to bytevector contents.
GNU General Public License v3.0
36 stars 6 forks source link

guile/pointer.scm speedup #22

Closed mwette closed 7 years ago

mwette commented 7 years ago

For efficiency, consider replacing

(define bytevector-address-ref
  (case pointer-size
    ((1) bytevector-u8-ref)
    ...
    ((8) bytevector-u64-native-ref)))

(define bytevector-address-set!
  (case pointer-size
    ((1) bytevector-u8-set!)
    ...
    ((8) bytevector-u64-native-set!)))

with

(define bytevector-address-ref
  (case pointer-size
    ((8) bytevector-u64-native-ref)
    ...
    ((1) bytevector-u8-ref)))

(define bytevector-address-set!
  (case pointer-size
    ((1) bytevector-u64-native-set!)
    ...
    ((2) bytevector-u8-set!)))
TaylanUB commented 7 years ago

Look at those forms more carefully. ;-) They just bind the bytevector-address-xyz identifiers conditionally to one of the procedures that appear in the arms of the case expression, at the time the define forms are evaluated.

mwette commented 7 years ago

On Sep 29, 2017, at 9:26 AM, TaylanUB notifications@github.com wrote:

Look at those forms more carefully. ;-) They just bind the bytevector-address-xyz identifiers conditionally to one of the procedures that appear in the arms of the case expression, at the time the define forms are evaluated.

Got it. They are not procedures. My bad. Sorry.

TaylanUB commented 7 years ago

No probs! Thanks for your feedback. :-)