perf: elf/macho u16/u32/u64 use native bytevector-uN-ref (one require-range per field, was per-byte)

ober

42699c8b5a78397f41952b9fe8e52975ffffb0e9

diff --git a/lib/jasm/object/elf.ss b/lib/jasm/object/elf.ss
index 5886412..70acce4 100644
--- a/lib/jasm/object/elf.ss
+++ b/lib/jasm/object/elf.ss
@@ -88,35 +88,18 @@
 
     (define (u16 bv offset endian)
       (require-range 'read-elf-bytevector bv offset 2)
-      (let ([b0 (u8 bv offset)]
-            [b1 (u8 bv (+ offset 1))])
-        (if (eq? endian 'little)
-            (+ b0 (* b1 #x100))
-            (+ (* b0 #x100) b1))))
+      (bytevector-u16-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (u32 bv offset endian)
       (require-range 'read-elf-bytevector bv offset 4)
-      (let ([b0 (u8 bv offset)]
-            [b1 (u8 bv (+ offset 1))]
-            [b2 (u8 bv (+ offset 2))]
-            [b3 (u8 bv (+ offset 3))])
-        (if (eq? endian 'little)
-            (+ b0
-               (* b1 #x100)
-               (* b2 #x10000)
-               (* b3 #x1000000))
-            (+ (* b0 #x1000000)
-               (* b1 #x10000)
-               (* b2 #x100)
-               b3))))
+      (bytevector-u32-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (u64 bv offset endian)
       (require-range 'read-elf-bytevector bv offset 8)
-      (if (eq? endian 'little)
-          (+ (u32 bv offset endian)
-             (* (u32 bv (+ offset 4) endian) #x100000000))
-          (+ (* (u32 bv offset endian) #x100000000)
-             (u32 bv (+ offset 4) endian))))
+      (bytevector-u64-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (s32 x)
       (if (>= x #x80000000) (- x #x100000000) x))
diff --git a/lib/jasm/object/macho.ss b/lib/jasm/object/macho.ss
index c9fcd13..45d9eb5 100644
--- a/lib/jasm/object/macho.ss
+++ b/lib/jasm/object/macho.ss
@@ -67,35 +67,18 @@
 
     (define (u16 bv offset endian)
       (require-range 'read-macho-bytevector bv offset 2)
-      (let ([b0 (u8 bv offset)]
-            [b1 (u8 bv (+ offset 1))])
-        (if (eq? endian 'little)
-            (+ b0 (* b1 #x100))
-            (+ (* b0 #x100) b1))))
+      (bytevector-u16-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (u32 bv offset endian)
       (require-range 'read-macho-bytevector bv offset 4)
-      (let ([b0 (u8 bv offset)]
-            [b1 (u8 bv (+ offset 1))]
-            [b2 (u8 bv (+ offset 2))]
-            [b3 (u8 bv (+ offset 3))])
-        (if (eq? endian 'little)
-            (+ b0
-               (* b1 #x100)
-               (* b2 #x10000)
-               (* b3 #x1000000))
-            (+ (* b0 #x1000000)
-               (* b1 #x10000)
-               (* b2 #x100)
-               b3))))
+      (bytevector-u32-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (u64 bv offset endian)
       (require-range 'read-macho-bytevector bv offset 8)
-      (if (eq? endian 'little)
-          (+ (u32 bv offset endian)
-             (* (u32 bv (+ offset 4) endian) #x100000000))
-          (+ (* (u32 bv offset endian) #x100000000)
-             (u32 bv (+ offset 4) endian))))
+      (bytevector-u64-ref bv offset
+        (if (eq? endian 'little) (endianness little) (endianness big))))
 
     (define (slice-bytevector bv offset size)
       (require-range 'macho-section-bytes bv offset size)