summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-13 11:19:34 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-13 11:19:34 +0000
commit0d0b553f7d0b5d3ab165ddbf4e1c6b47fe6e17d9 (patch)
treed5f5ef8a179f09a4565a9a3f1dc90600f1b86e9f
parent06f691903174243e9da8c61a845a03953d9cad5f (diff)
*** no comment ***
-rw-r--r--TODO29
-rw-r--r--chess-display.el24
2 files changed, 31 insertions, 22 deletions
diff --git a/TODO b/TODO
index a79dd46..2f62bf6 100644
--- a/TODO
+++ b/TODO
@@ -1,20 +1,17 @@
-Aha! I knew there had to be a way. The old keyboard shortcutting
-code (which uses chess-legal-plies) was just way to slow. On modern
-machines you couldn't notice it, but on my 300 MHz laptop in battery
-save mode, even with the byte-compiled files, I spent 1/4 of my time
-looking at the hourglass cursor. So I kept chewing on the algorithm,
+delYsid: I knew there had to be a way. The old keyboard shortcutting
+code (which uses chess-legal-plies) was just to slow. On modern
+machines you wouldn't notice it, but on my 300 MHz laptop in battery
+saving mode, even with byte-compiled files, I spent 1/4 of my time
+looking at the hourglass cursor. So I kept cleaning the algorithm,
dropping the number of calls to chess-search-position (the biggest and
-slowest function in all of chess.el) from 5400 calls down to 4300
-calls. But still it was slow. Then I thought about it long and hard,
-and realized chess-legal-plies was going about its whole job
-backwards. Since that function is only used by keyboard shortcutting,
-I found a way to optimize it for that task, while keeping it as
-general as before (by adding a "piece-or-color" argument). The net
-result is that I got the number of calls to chess-search-position down
-to 797!! That's 5000 calls less. It dropped the number of uses of
-`chess-incr-index' by 20,000. The new code is so fast I that when
-it's byte-compiled, I never see an hourglass cursor, even on my
-laptop.
+slowest function in chess.el) from 5400 calls down to 4300 calls. But
+still it was too slow. Then I thought about it long and hard, and
+realized chess-legal-plies was going about its whole job backwards. I
+found a way to optimize it that resulted in dropping the number of
+calls to chess-search-position down to 797!! That's 5000 fewer calls.
+The new code is so fast I that when it's byte-compiled, I never see an
+hourglass cursor, rarely even when un-byte-compiled in my slowest
+configuration!
- Feature work remaining:
diff --git a/chess-display.el b/chess-display.el
index cc0106a..58a2e0c 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -443,25 +443,37 @@ The key bindings available in this mode are:
(setq buffer-auto-save-file-name nil
mode-line-format 'chess-display-mode-line))
+(chess-message-catalog 'english
+ '((mode-white . "White")
+ (mode-black . "Black")
+ (mode-start . "START")
+ (mode-checkmate . "CHECKMATE")
+ (mode-resigned . "RESIGNED")
+ (mode-stalemate . "STALEMATE")
+ (mode-drawn . "DRAWMN")))
+
(defun chess-display-set-modeline ()
"Set the modeline to reflect the current game position."
(let ((color (chess-pos-side-to-move (chess-display-position nil)))
(index chess-display-index))
(if (= index 0)
(setq chess-display-mode-line
- (format " %s START" (if color "White" "Black")))
+ (format " %s %s" (if color (chess-string 'mode-white)
+ (chess-string 'mode-black))
+ (chess-string 'mode-start)))
(let ((ply (chess-game-ply chess-display-game (1- index))))
(setq chess-display-mode-line
(concat
" "
(let ((final (chess-ply-final-p ply)))
(cond
- ((eq final :checkmate) "CHECKMATE")
- ((eq final :resign) "RESIGNED")
- ((eq final :stalemate) "STALEMATE")
- ((eq final :draw) "DRAWN")
+ ((eq final :checkmate) (chess-string 'mode-checkmate))
+ ((eq final :resign) (chess-string 'mode-resigned))
+ ((eq final :stalemate) (chess-string 'mode-stalemate))
+ ((eq final :draw) (chess-string 'mode-drawn))
(t
- (if color "White" "Black"))))
+ (if color (chess-string 'mode-white)
+ (chess-string 'mode-black)))))
(if index
(concat " " (int-to-string
(if (> index 1)