comparison lisp/subr.el @ 4267:66e2714696bd

[xemacs-hg @ 2007-11-14 19:25:39 by aidan] Make string-to-list, string-to-sequence faster, simpler (change from GNU).
author aidan
date Wed, 14 Nov 2007 19:25:40 +0000
parents c5a2b80bc4fa
children d9eb5ea14f65
comparison
equal deleted inserted replaced
4266:c5a2b80bc4fa 4267:66e2714696bd
945 (defun string-to-sequence (string type) 945 (defun string-to-sequence (string type)
946 "Convert STRING to a sequence of TYPE which contains characters in STRING. 946 "Convert STRING to a sequence of TYPE which contains characters in STRING.
947 TYPE should be `list' or `vector'." 947 TYPE should be `list' or `vector'."
948 (ecase type 948 (ecase type
949 (list 949 (list
950 (mapcar #'identity string)) 950 (append string nil))
951 (vector 951 (vector
952 (mapvector #'identity string)))) 952 (vconcat string))))
953 953
954 (defun string-to-list (string) 954 (defun string-to-list (string)
955 "Return a list of characters in STRING." 955 "Return a list of characters in STRING."
956 (mapcar #'identity string)) 956 (append string nil))
957 957
958 (defun string-to-vector (string) 958 (defun string-to-vector (string)
959 "Return a vector of characters in STRING." 959 "Return a vector of characters in STRING."
960 (mapvector #'identity string)) 960 (vconcat string))
961 961
962 (defun store-substring (string idx obj) 962 (defun store-substring (string idx obj)
963 "Embed OBJ (string or character) at index IDX of STRING." 963 "Embed OBJ (string or character) at index IDX of STRING."
964 (let* ((str (cond ((stringp obj) obj) 964 (let* ((str (cond ((stringp obj) obj)
965 ((characterp obj) (char-to-string obj)) 965 ((characterp obj) (char-to-string obj))