Skip to content

Commit

Permalink
disable interrupts in strio inline methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Jul 27, 2023
1 parent d08139a commit 07e215d
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions src/std/io/strio/inline.ss
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,43 @@
(export #t)

(defrule (&BufferedStringReader-peek-char-inline reader)
(let (strbuf (&interface-instance-object reader))
(let ((rlo (&string-input-buffer-rlo strbuf))
(rhi (&string-input-buffer-rhi strbuf))
(buf (&string-input-buffer-buf strbuf)))
(if (fx< rlo rhi)
(string-ref buf rlo)
;; empty buffer, fall back to the method
(strbuf-peek-char strbuf)))))
(let ()
(declare (not interrupts-enabled))
(let (strbuf (&interface-instance-object reader))
(let ((rlo (&string-input-buffer-rlo strbuf))
(rhi (&string-input-buffer-rhi strbuf))
(buf (&string-input-buffer-buf strbuf)))
(if (fx< rlo rhi)
(string-ref buf rlo)
;; empty buffer, fall back to the method
(strbuf-peek-char strbuf))))))

(defrule (&BufferedStringReader-read-char-inline reader)
(let (strbuf (&interface-instance-object reader))
(let ((rlo (&string-input-buffer-rlo strbuf))
(rhi (&string-input-buffer-rhi strbuf))
(buf (&string-input-buffer-buf strbuf)))
(if (fx< rlo rhi)
(let ((char (string-ref buf rlo))
(rlo+1 (fx+ rlo 1)))
(strbuf-input-advance! strbuf rlo+1 rhi)
char)
;; empty buffer, fall back to the method
(strbuf-read-char strbuf)))))
(let ()
(declare (not interrupts-enabled))
(let (strbuf (&interface-instance-object reader))
(let ((rlo (&string-input-buffer-rlo strbuf))
(rhi (&string-input-buffer-rhi strbuf))
(buf (&string-input-buffer-buf strbuf)))
(if (fx< rlo rhi)
(let ((char (string-ref buf rlo))
(rlo+1 (fx+ rlo 1)))
(strbuf-input-advance! strbuf rlo+1 rhi)
char)
;; empty buffer, fall back to the method
(strbuf-read-char strbuf))))))

(defrule (&BufferedStringWriter-write-char-inline writer char)
(let (strbuf (&interface-instance-object writer))
(let* ((whi (&string-output-buffer-whi strbuf))
(buf (&string-output-buffer-buf strbuf))
(buflen (string-length buf)))
(if (fx< whi buflen)
(let (whi+1 (fx+ whi 1))
(string-set! buf whi char)
(strbuf-output-advance! strbuf whi+1)
1)
;; full buffer, fall back to the method
(strbuf-write-char strbuf char)))))
(let ()
(declare (not interrupts-enabled))
(let (strbuf (&interface-instance-object writer))
(let* ((whi (&string-output-buffer-whi strbuf))
(buf (&string-output-buffer-buf strbuf))
(buflen (string-length buf)))
(if (fx< whi buflen)
(let (whi+1 (fx+ whi 1))
(string-set! buf whi char)
(strbuf-output-advance! strbuf whi+1)
1)
;; full buffer, fall back to the method
(strbuf-write-char strbuf char))))))

0 comments on commit 07e215d

Please sign in to comment.