shithub: sl

Download patch

ref: 6fb39cada9341c71ed697f74a05b241348bd412b
parent: 5019c474f1124000e20065f3fcae200ab798e9f8
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Mar 17 17:45:07 EDT 2025

simple-sort: move out of visibility

--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -311,16 +311,21 @@
 xpand-define) #fn("n20T20A<71051222324F1>2865215252P:" #(begin cddr #fn(nconc)
                                                                            #fn(map)
                                                                            #fn("n10<70A<0TF525150Fe3:" #(compile-thunk))) expand-let-syntax)
-TF525150Fe3:" #(compile-thunk))) expand-let-syntax)
-  #fn("n20:" #() local-expansion-env) #fn("n20H3400:0<208615221A10>3873P087=B3I0A<87T0=f2F<72875115262:73051893>0A<890=f2162:87;J?0486RS;J60486Z3708860:8624C400:8625C:092<0162:8625C:092<0162:8626C:093<0162:8627C:094<0162:8860:" #(#fn(assq)
-  #fn("n0Ib48420AF84>3_484<^19261:" #(#fn("n10H3400:0<H3700<@90A<0<F5292<0=51P:" #()))) caddr
-  macrocall? quote λ def let-syntax) expand-in)) macroexpand)
+TF525150Fe3:" #(compile-thunk))) expand-let-syntax)
+  #fn("n20:" #() local-expansion-env) #fn("n20H3400:0<208615221A10>3873P087=B3I0A<87T0=f2F<72875115262:73051893>0A<890=f2162:87;J?0486RS;J60486Z3708860:8624C400:8625C:092<0162:8625C:092<0162:8626C:093<0162:8627C:094<0162:8860:" #(#fn(assq)
+  #fn("n0Ib48420AF84>3_484<^19261:" #(#fn("n10H3400:0<H3700<@90A<0<F5292<0=51P:" #()))) caddr
+  macrocall? quote λ def let-syntax) expand-in)) macroexpand)
+            macroexpand-1 #fn("n10H3400:7005185390850=}2:0:" #(macrocall?) macroexpand-1)
+            make-code-emitter #fn("n0q2050EqEo5:" #(#fn(table)) make-code-emitter)
+            make-perfect-hash-table #fn("n1Ib5208521_514Ib6862285860>3_486<^12305161:" #(#1#
 rocall? quote λ def let-syntax) expand-in)) macroexpand)
-("n10H3400:7005185390850=}2:0:" #(macrocall?) macroexpand-1)
-            make-code-emitter #fn("n0q2050EqEo5:" #(#fn(table)) make-code-emitter)
-            make-perfect-hash-table #fn("n1Ib5208521_514Ib6862285860>3_486<^12305161:" #(#1#
-  #fn("n270712205151162:" #(mod0 abs #fn(hash)) $hash-keyword)
-  #fn("n120r20i2q52Ib68621A085F86>5_486<^19261:" #(#fn(vec-alloc)
+#(mod0 abs #fn(hash)) $hash-keyword)
+  #fn("n120r20i2q52Ib68621A085F86>5_486<^19261:" #(#fn(vec-alloc)
+                                                   #fn("n10B3p070051r2A<85F52i29286G3;093<FKM61:928685p49286KM71051p494<0=61:92:" #(caar
+  cdar)))) #fn(length)) make-perfect-hash-table)
+            make-system-image #fn("n1Ib520852185>1_51422023242554267778Dw74Dw84298889>22:878586>32;8:>1{8:504:" #(#0#
+  #fn("n10S;J6040=S3400:0<7021850>222A85>262:" #(call-with-values #fn("n07021A>1F=62:" #(partition
+  #fn("n10AL2:" #()))) #fn("n220A<051Fe1A<15163:" #(#fn(nconc)))) sort)
  #fn("n120021222354247576Dw54Dw64278788>2288685>22989>1{89504:" #(#fn(file)
   :write :create :truncate (*linefeed* *directory-separator* *argv* that *exit-hooks*
                                        *print-pretty* *print-width* *print-readably* *print-level*
@@ -392,8 +397,6 @@
 )
             repl #fn("n0IIb4b5208421_5142085228485>2_51485<5047360:" #(#0#
                                                                        #fn("n07050421725142324{257651S;3Z04778451788551360q@=079855147:5047;85w<61:" #(*prompt*
-788551360q@=079855147:5047;85w<61:" #(*prompt*
-  #fn(io-flush) *io-out* #fn("n02060:" #(#fn(read)))
 print newline void that) prompt)
                                                                        #fn("n020A>121{370F<60:q:" #(#fn("n0A<60:" #())
   #fn("n1700514D:" #(top-level-exception-handler))) reploop) newline) repl)
--- a/src/system.lsp
+++ b/src/system.lsp
@@ -1335,17 +1335,16 @@
 
   (princ *linefeed*))
 
-(def (simple-sort l)
-  (if (or (not l) (not (cdr l)))
-      l
-      (let ((piv (car l)))
-        (receive (less grtr)
-                 (partition (λ (x) (< x piv)) (cdr l))
-                 (nconc (simple-sort less)
-                        (list piv)
-                        (simple-sort grtr))))))
-
 (def (make-system-image fname)
+  (def (sort l)
+    (if (or (not l) (not (cdr l)))
+        l
+        (let ((piv (car l)))
+          (receive (less grtr)
+                   (partition (λ (x) (< x piv)) (cdr l))
+                   (nconc (sort less)
+                          (list piv)
+                          (sort grtr))))))
   (let ((f (file fname :write :create :truncate))
         (excludes '(*linefeed* *directory-separator* *argv* that *exit-hooks*
                     *print-pretty* *print-width* *print-readably*
@@ -1362,7 +1361,7 @@
                                               (str (top-level-value s)))))
                              (not (memq s excludes))
                              (not (io? (top-level-value s)))))
-                      (simple-sort (environment))))
+                      (sort (environment))))
              (data (apply nconc (map list syms (map top-level-value syms)))))
         (write data f)
         (io-write f *linefeed*))
--- a/test/perf.lsp
+++ b/test/perf.lsp
@@ -22,6 +22,16 @@
 (princ "yfib(32): ")
 (assert (equal? (time (yfib 32)) 2178309))
 
+(def (simple-sort l)
+  (if (or (not l) (not (cdr l)))
+      l
+      (let ((piv (car l)))
+        (receive (less grtr)
+                 (partition (λ (x) (< x piv)) (cdr l))
+                 (nconc (simple-sort less)
+                        (list piv)
+                        (simple-sort grtr))))))
+
 (princ "sort: ")
 (set! r (map-int (λ (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
 (time (simple-sort r))