diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-17 00:46:47 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-17 00:46:47 +0000 |
| commit | 60422a39cde50972f6f73e2b55b35fdb446e74fd (patch) | |
| tree | 2b3ff30cb45e0a2511a66e05b93c95b3b29ab8e0 | |
| parent | f39edf2a33b9ba4ee33aa3fe05e0e0dee6ac4bfc (diff) | |
Further speed tweaks
| -rw-r--r-- | chess-display.el | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/chess-display.el b/chess-display.el index e62b059..5c80f62 100644 --- a/chess-display.el +++ b/chess-display.el @@ -187,7 +187,7 @@ also view the same game." ((eq status :checkmate) (chess-string 'mode-checkmate)) ((eq status :stalemate) (chess-string 'mode-stalemate)) (t - (if (chess-game-side-to-move chess-module-game) + (if (chess-pos-side-to-move (chess-display-position nil)) (chess-string 'mode-white) (chess-string 'mode-black))))))))) @@ -218,6 +218,28 @@ also view the same game." (erase-buffer) (chess-display-update nil))) +(defvar chess-display-index-positions nil) + +(make-variable-buffer-local 'chess-display-index-positions) + +(defun chess-display-index-pos (display index) + (chess-with-current-buffer display + (unless chess-display-index-positions + (setq chess-display-index-positions (make-vector 64 nil)) + (let ((pos (next-single-property-change (point-min) 'chess-coord)) + pos-index) + (while pos + (if (setq pos-index (get-text-property pos 'chess-coord)) + (aset chess-display-index-positions pos-index pos)) + (setq pos (next-single-property-change pos 'chess-coord))) + (unless (aref chess-display-index-positions 0) + (aset chess-display-index-positions 0 (point-min))))) + (aref chess-display-index-positions index))) + +(defsubst chess-display-goto-index (index) + (chess-with-current-buffer display + (goto-char (chess-display-index-pos nil index)))) + (defun chess-display-paint-move (display ply) (chess-with-current-buffer display (let ((position (chess-ply-pos ply)) @@ -1004,20 +1026,6 @@ Clicking once on a piece selects it; then click on the target location." (goto-char (posn-point (event-end event))) (chess-display-select-piece)))) -(defun chess-display-index-pos (display index) - (chess-with-current-buffer display - (let ((pos (next-single-property-change (point-min) 'chess-coord)) - pos-index) - (while (and pos (or (null (setq pos-index - (get-text-property pos 'chess-coord))) - (/= index pos-index))) - (setq pos (next-single-property-change pos 'chess-coord))) - pos))) - -(defsubst chess-display-goto-index (index) - (chess-with-current-buffer display - (goto-char (chess-display-index-pos nil index)))) - (provide 'chess-display) ;;; chess-display.el ends here |
