summaryrefslogtreecommitdiff
path: root/lisp/rot13.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-11-16 22:48:37 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2021-11-16 22:48:37 -0500
commit1a4f210c246688519f85db72bdc3bea536cb5dbe (patch)
tree86eb0971d7af378d87ecc7d090eb05dfacf379a2 /lisp/rot13.el
parent4c467e4aff12e65fa4fa62d7f4bdcbf4a2bcd92c (diff)
downloademacs-1a4f210c246688519f85db72bdc3bea536cb5dbe.tar.gz
emacs-1a4f210c246688519f85db72bdc3bea536cb5dbe.tar.bz2
emacs-1a4f210c246688519f85db72bdc3bea536cb5dbe.zip
* lisp/rot13.el (rot13-translate-table): Make it a `translation-table`
(rot13-display-table): Use `dotimes`.
Diffstat (limited to 'lisp/rot13.el')
-rw-r--r--lisp/rot13.el32
1 files changed, 13 insertions, 19 deletions
diff --git a/lisp/rot13.el b/lisp/rot13.el
index 4e4e60fea3f..e509b22529f 100644
--- a/lisp/rot13.el
+++ b/lisp/rot13.el
@@ -46,29 +46,23 @@
;;; Code:
-(defvar rot13-display-table
- (let ((table (make-display-table))
- (i 0))
- (while (< i 26)
+(defconst rot13-display-table
+ (let ((table (make-display-table)))
+ (dotimes (i 26)
(aset table (+ i ?a) (vector (+ (% (+ i 13) 26) ?a)))
- (aset table (+ i ?A) (vector (+ (% (+ i 13) 26) ?A)))
- (setq i (1+ i)))
+ (aset table (+ i ?A) (vector (+ (% (+ i 13) 26) ?A))))
table)
"Char table for ROT13 display.")
-(defvar rot13-translate-table
- (let ((str (make-string 127 0))
- (i 0))
- (while (< i 127)
- (aset str i i)
- (setq i (1+ i)))
- (setq i 0)
- (while (< i 26)
- (aset str (+ i ?a) (+ (% (+ i 13) 26) ?a))
- (aset str (+ i ?A) (+ (% (+ i 13) 26) ?A))
- (setq i (1+ i)))
- str)
- "String table for ROT13 translation.")
+(put 'plain-char-table 'char-table-extra-slots 0)
+
+(defconst rot13-translate-table
+ (let ((table (make-char-table 'translation-table)))
+ (dotimes (i 26)
+ (aset table (+ i ?a) (+ (% (+ i 13) 26) ?a))
+ (aset table (+ i ?A) (+ (% (+ i 13) 26) ?A)))
+ table)
+ "Char table for ROT13 translation.")
;;;###autoload
(defun rot13 (object &optional start end)