(define-integrable (accum->string a)
(set-string-maximum-length! (car a) (cdr a))
- ;; jrm's port cannot resize strings, so if the
- ;; resize didn't work, just take the substring.
- (if (fix:= (string-maximum-length (car a)) (cdr a))
- (car a)
- (substring (car a) 0 (cdr a))))
+ (car a))
(define-integrable (accum-count a)
(cdr a))
(let* ((escaped (make-string (fix:* 2 (string-length string))))
(length (pq-escape-string string escaped)))
(set-string-maximum-length! escaped length)
- (if (fix:= (string-maximum-length escaped) length)
- escaped
- (substring escaped 0 length))))
+ escaped))
(define (encode-pgsql-bytea bytes)
(guarantee-pgsql-available)
(define (narrow-out/extract-output! port)
(let* ((os (port/state port))
- (string (ostate-buffer os))
- (length (ostate-index os)))
- (set-string-maximum-length! string length)
+ (string (ostate-buffer os)))
+ (set-string-maximum-length! string (ostate-index os))
(reset-buffer! os)
- (if (fix:= (string-maximum-length string) length)
- string
- (substring string 0 length))))
+ string))
(define (make-wide-output-type)
(make-string-out-type wide-out/write-char
(define (octets-out/extract-output! port)
(output-port/flush-output port)
(let* ((os (output-octets-port/os port))
- (octets (ostate-buffer os))
- (length (ostate-index os)))
- (set-string-maximum-length! octets length)
- (set-ostate-buffer! os (make-vector-8b 16))
- (set-ostate-index! os 0)
- (if (fix:= (string-maximum-length octets) length)
- octets
- (substring octets 0 length))))
+ (octets (ostate-buffer os)))
+ (set-string-maximum-length! octets (ostate-index os))
+ (set-ostate-buffer! os (make-vector-8b 16))
+ (set-ostate-index! os 0)
+ octets))
(define (octets-out/position port)
(output-port/flush-output port)