Chicken Shen

Check-in [6308af6aff]
Login
Overview
Comment:Implemented read-file-as-bytelist with no decrease in boot time
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | fasterFileAccess
Files: files | file ages | folders
SHA3-256:6308af6affdffe1f76c667cbc9c0c1c2cf22e7a45399ccbdbdda195bcca97c46
User & Date: david 2019-02-02 12:22:11
Context
2019-02-02
12:22
Implemented read-file-as-bytelist with no decrease in boot time Leaf check-in: 6308af6aff user: david tags: fasterFileAccess
11:35
Create new branch named "fasterFileAccess" check-in: 86e7cb789f user: david tags: fasterFileAccess
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to klambda.scm.

27
28
29
30
31
32
33









34
35
36
37
38
39
40
...
119
120
121
122
123
124
125


126
127


128
129
130
131
132




133
134
135
136
137
138
139
140
141
;;;  \____|_|\___/|_.__/ \__,_|_|___/

(define *code->char*            (make-hash-table))
(define *char->code*            (make-hash-table))
(define *code->unicode*         (make-hash-table))
(define *shen-globals*          (make-hash-table))
(define *shen-function-arities* (make-hash-table))










;;;  _____                 _   _
;;; |  ___|   _ _ __   ___| |_(_) ___  _ __
;;; | |_ | | | | '_ \ / __| __| |/ _ \| '_ \ 
;;; |  _|| |_| | | | | (__| |_| | (_) | | | |
;;; |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|
;;;
................................................................................
  (if (boolean? value)
      value
      (error 'assert-boolean "expected a boolean, got" value)))

(define (char-code char)
  (if (hash-table-exists? *char->code* char)
      (hash-table-ref *char->code* char)


      (simple-error "can't find code for given character")))
      ;; 63)) ;;; Return ? code if we can't find the char


      

(define (code-char code)
  (if (hash-table-exists? *code->char* code)
      (hash-table-ref *code->char* code)




      (simple-error "can't find character with given code")))
      ;; #\?)) ;;; Return ? if we can't find the char

;;;  _  __     _                    _         _
;;; | |/ /    | |    __ _ _ __ ___ | |__   __| | __ _
;;; | ' /_____| |   / _` | '_ ` _ \| '_ \ / _` |/ _` |
;;; | . \_____| |__| (_| | | | | | | |_) | (_| | (_| |
;;; |_|\_\    |_____\__,_|_| |_| |_|_.__/ \__,_|\__,_|








>
>
>
>
>
>
>
>
>







 







>
>
|
<
>
>
|
<



>
>
>
>
|
<







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
128
129
130
131
132
133
134
135
136
137

138
139
140

141
142
143
144
145
146
147
148

149
150
151
152
153
154
155
;;;  \____|_|\___/|_.__/ \__,_|_|___/

(define *code->char*            (make-hash-table))
(define *char->code*            (make-hash-table))
(define *code->unicode*         (make-hash-table))
(define *shen-globals*          (make-hash-table))
(define *shen-function-arities* (make-hash-table))


(define (file-port? port)
  (not
   (or
    (string=? "(stdout)" (port-name port))
    (string=? "(stdin)"  (port-name port))
    (string=? "(stderr)" (port-name port)))))


;;;  _____                 _   _
;;; |  ___|   _ _ __   ___| |_(_) ___  _ __
;;; | |_ | | | | '_ \ / __| __| |/ _ \| '_ \ 
;;; |  _|| |_| | | | | (__| |_| | (_) | | | |
;;; |_|   \__,_|_| |_|\___|\__|_|\___/|_| |_|
;;;
................................................................................
  (if (boolean? value)
      value
      (error 'assert-boolean "expected a boolean, got" value)))

(define (char-code char)
  (if (hash-table-exists? *char->code* char)
      (hash-table-ref *char->code* char)
      (begin
	(let ((msg
	       (string-append "can't find code for given character: "

			      (make-string 1 char))))
	  (simple-error msg)))))
			      

(define (code-char code)
  (if (hash-table-exists? *code->char* code)
      (hash-table-ref *code->char* code)
      (begin
	(let ((msg
	       (string-append "can't find char with code: "
			      (number->string code))))
	  (simple-error msg)))))


;;;  _  __     _                    _         _
;;; | |/ /    | |    __ _ _ __ ___ | |__   __| | __ _
;;; | ' /_____| |   / _` | '_ ` _ \| '_ \ / _` |/ _` |
;;; | . \_____| |__| (_| | | | | | | |_) | (_| | (_| |
;;; |_|\_\    |_____\__,_|_| |_| |_|_.__/ \__,_|\__,_|

Changes to shen-core.scm.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
..
46
47
48
49
50
51
52












53
54
55
56
57
58
59
  chicken.load
  chicken.base
  chicken.port
  chicken.file
  chicken.format
  chicken.irregex
  chicken.condition

  chicken.process-context)

;;; K-Lambda 
(include "klambda.scm")

;;; Shen
(include "shen-chicken/toplevel.kl.scm")
................................................................................
;;;  / _ \__   _____ _ ____      ___ __(_) |_ ___  ___
;;; | | | \ \ / / _ \ '__\ \ /\ / / '__| | __/ _ \/ __|
;;; | |_| |\ V /  __/ |   \ V  V /| |  | | ||  __/\__ \
;;;  \___/  \_/ \___|_|    \_/\_/ |_|  |_|\__\___||___/

;;; Overwrites interal Shen procedures for better performance.













(define (kl:map V2961 V2962)
  (map V2961 V2962))

(define (kl:append V2735 V2736)
  (append V2735 V2736))

(define (kl:sum V2899)







>







 







>
>
>
>
>
>
>
>
>
>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  chicken.load
  chicken.base
  chicken.port
  chicken.file
  chicken.format
  chicken.irregex
  chicken.condition
  chicken.file.posix
  chicken.process-context)

;;; K-Lambda 
(include "klambda.scm")

;;; Shen
(include "shen-chicken/toplevel.kl.scm")
................................................................................
;;;  / _ \__   _____ _ ____      ___ __(_) |_ ___  ___
;;; | | | \ \ / / _ \ '__\ \ /\ / / '__| | __/ _ \/ __|
;;; | |_| |\ V /  __/ |   \ V  V /| |  | | ||  __/\__ \
;;;  \___/  \_/ \___|_|    \_/\_/ |_|  |_|\__\___||___/

;;; Overwrites interal Shen procedures for better performance.

(define (kl:read-file-as-bytelist filename)
  (let ((fd (file-open filename
		       (+ open/rdonly))))
    (let loop ((contents "")
	       (data (file-read fd 1024)))
      (if (>  (cadr data) 0)
	  (loop (string-append contents (car data))
		(file-read fd 1024))
	  (begin
	    (file-close fd)
	    (map char-code (string->list contents)))))))

(define (kl:map V2961 V2962)
  (map V2961 V2962))

(define (kl:append V2735 V2736)
  (append V2735 V2736))

(define (kl:sum V2899)