perf: elf/macho symbol+relocation+section accumulation cons-then-reverse (was append-reverse per section)

ober

08f51930c719c08c6e6720c94b8e85e7e639f098

diff --git a/lib/jasm/object/elf.ss b/lib/jasm/object/elf.ss
index 70acce4..c9cdc30 100644
--- a/lib/jasm/object/elf.ss
+++ b/lib/jasm/object/elf.ss
@@ -407,8 +407,9 @@
             [(null? remaining) (reverse symbols)]
             [(symbol-table-section? (car remaining))
              (loop (cdr remaining)
-                   (append (reverse (parse-symbols-for-section class endian bv all-sections (car remaining)))
-                           symbols))]
+                   (let add ([xs (parse-symbols-for-section class endian bv all-sections (car remaining))]
+                             [acc symbols])
+                     (if (null? xs) acc (add (cdr xs) (cons (car xs) acc)))))]
             [else (loop (cdr remaining) symbols)]))))
 
     (define (relocation-section? section)
@@ -470,8 +471,9 @@
           [(null? sections) (reverse relocations)]
           [(relocation-section? (car sections))
            (loop (cdr sections)
-                 (append (reverse (parse-relocations-for-section class endian bv (car sections)))
-                         relocations))]
+                 (let add ([xs (parse-relocations-for-section class endian bv (car sections))]
+                           [acc relocations])
+                   (if (null? xs) acc (add (cdr xs) (cons (car xs) acc)))))]
           [else (loop (cdr sections) relocations)])))
 
     (define (read-elf-bytevector bv . maybe-path)
diff --git a/lib/jasm/object/macho.ss b/lib/jasm/object/macho.ss
index 45d9eb5..bdc2a90 100644
--- a/lib/jasm/object/macho.ss
+++ b/lib/jasm/object/macho.ss
@@ -188,15 +188,16 @@
                 (error 'read-macho-bytevector "Mach-O load command size is too small" cmdsize))
               (require-range 'read-macho-bytevector bv offset cmdsize)
               (cond
-                [(= cmd #x19)
-                 (let* ([result (parse-segment-64 endian bv offset cmdsize section-index)]
-                        [next-index (car result)]
-                        [new-sections (cdr result)])
-                   (loop (+ i 1)
-                         (+ offset cmdsize)
-                         next-index
-                         (append (reverse new-sections) sections)
-                         symtab))]
+                 [(= cmd #x19)
+                  (let* ([result (parse-segment-64 endian bv offset cmdsize section-index)]
+                         [next-index (car result)]
+                         [new-sections (cdr result)])
+                    (loop (+ i 1)
+                          (+ offset cmdsize)
+                          next-index
+                          (let add ([xs new-sections] [acc sections])
+                            (if (null? xs) acc (add (cdr xs) (cons (car xs) acc))))
+                          symtab))]
                 [(= cmd #x2)
                  (when (< cmdsize 24)
                    (error 'read-macho-bytevector "Mach-O symtab command is too small" cmdsize))