Improve correctness and function declarations
Correctness changes:
-
joinnow treats anilseparator as the empty string, rather than the string"nil", conforming to the semantics in the README of not convertingnilto"nil". -
containspnow automatically returnsnilif either string input isnil. -
alphanumpand similar now use the correct regex checks for multi-line strings, rather than accepting an input if it has any line matching their specification.
Optimization changes:
- Multiple non-recursive functions have been inlined
- Multiple functions have
ftypedeclarations - In local testing, there is a ~0.1s reduction from ~1.05s to ~0.95s in
(time (dotimes (i 100) (with-output-to-string (throwaway) (let ((*standard-output* throwaway)) (asdf:test-system :str))))), despite the new tests in this version.- Note: Most of the tests use
constantpinputs, so performance improvements here derive mainly from the inlining; they do not represent benefits from theftypedeclarations in user-code. - Note: The comparison was specifically with the contents of https://github.com/vindarel/cl-str/pull/128, but that still shows an improvement over the original.
- Note: Most of the tests use
excellent, thanks, it looks good, though I'll take more time to test in the wild, because merging bad type declarations can be very annoying (and imagine if Quicklisp releases in-between our quick fixes). I encourage anyone to try this PR.
hey btw I have compilation warnings "deleting unreachable code" for the pad-* functions:
; in: DEFUN PAD-LEFT
; (STR:PAD STR::LEN STR::S :PAD-SIDE :LEFT :PAD-CHAR STR::PAD-CHAR)
; --> BLOCK LET IF FLET STR::%PAD-CENTER BLOCK MULTIPLE-VALUE-BIND
; --> MULTIPLE-VALUE-CALL FLOOR -
; ==>
; STR::LEN
;
; note: deleting unreachable code
; --> BLOCK LET IF FLET STR::%PAD-RIGHT BLOCK CONCATENATE
; ==>
; STR::S
;
; note: deleting unreachable code
[…]
Isn't there an issue when the arguments len s pad-char are the same than the mother pad function?
I would do this:
(declaim (inline pad-left))
(defun pad-left (%len %s &key (%pad-char *pad-char*)) ;; %len
(pad %len %s :pad-side :left :pad-char %pad-char))
;; same for pad-right
or remove their inline declaration. @swapneils ?
Thanks for looking into the compile failures! I'll aim to check that change this weekend and see if a (few-months-old) source build of SBCL raises anything else. Been pretty busy with work and work-adjacent stuff the last few months.
No more pad-* compilation warnings with a newer compiler (SBCL 2.5.8).