Ignore:
Timestamp:
Nov 1, 2010, 11:28:33 PM (9 years ago)
Author:
gb
Message:

Try to make string-output-stream creation a little faster.
Amazingly enough, not creating a string-output-stream is still
faster than creating one is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-streams.lisp

    r14365 r14397  
    43074307                   *string-output-stream-class-wrapper*)
    43084308               (eq (string-output-stream-ioblock-freelist ioblock) pool))
    4309     (without-interrupts
    4310      (setf (ioblock-stream ioblock) (pool.data pool)
    4311            (pool.data pool) ioblock)))))
     4309      (without-interrupts
     4310       (setf (ioblock-stream ioblock) (pool.data pool)
     4311             (pool.data pool) ioblock)))))
    43124312
    43134313;;; If this is the sort of string stream whose ioblock we recycle and
     
    43224322
    43234323
    4324 (defun create-string-output-stream-ioblock (&rest keys &key stream &allow-other-keys)
    4325   (declare (dynamic-extent keys))
     4324(defun create-string-output-stream-ioblock (stream string write-char-function write-string-function)
    43264325  (let* ((recycled (and stream
    43274326                        (eq (basic-stream.wrapper stream)
     
    43384337                                   (string-output-stream-ioblock-line-length data) 80))
    43394338                           data)))))
    4340     (or recycled (apply #'make-string-output-stream-ioblock keys))))
     4339    (or recycled
     4340        (make-string-output-stream-ioblock :stream stream
     4341                                           :string string
     4342                                           :element-type 'character
     4343                                           :write-char-function write-char-function
     4344                                           :write-char-when-locked-function write-char-function
     4345                                           :write-simple-string-function write-string-function
     4346                                           :force-output-function #'false
     4347                                           :freelist (%string-stream-ioblock-freelist stream)
     4348                                           :close-function #'%close-string-output-stream
     4349                                           :device -1))))
    43414350                       
    43424351
    43434352
    43444353(defun %%make-string-output-stream (class string write-char-function write-string-function)
    4345   (let* ((stream (allocate-basic-stream class)))
    4346     (initialize-basic-stream stream :element-type 'character)
    4347     (let* ((ioblock (create-string-output-stream-ioblock
    4348                      :stream stream
    4349                      :string string
    4350                      :element-type 'character
    4351                      :write-char-function write-char-function
    4352                      :write-char-when-locked-function write-char-function
    4353                      :write-simple-string-function write-string-function
    4354                      :force-output-function #'false
    4355                      :freelist (%string-stream-ioblock-freelist stream)
    4356                      :close-function #'%close-string-output-stream)))
     4354  (let* ((stream (gvector :basic-stream (%class.own-wrapper class)
     4355                          (logior (ash 1 basic-stream-flag.open-character)
     4356                                  (ash 1 basic-stream-flag.open-output))
     4357                          nil
     4358                          nil))
     4359         (ioblock (create-string-output-stream-ioblock stream string write-char-function write-string-function)))
    43574360      (setf (basic-stream.state stream) ioblock)
    4358       stream)))
     4361      stream))
    43594362
    43604363(declaim (inline %string-push-extend))
Note: See TracChangeset for help on using the changeset viewer.