summaryrefslogtreecommitdiff
path: root/chess-pos.el
diff options
context:
space:
mode:
authorMario Lang <mlang@delysid.org>2014-04-20 13:37:06 +0200
committerMario Lang <mlang@delysid.org>2014-04-20 13:37:06 +0200
commit5d5498f2d5cf0318e78329e987d2c476b0df48f7 (patch)
tree054ac77518fd228aecb1bfa53381b7f64852b1a5 /chess-pos.el
parent99be487e1dcfebd0dc89aa5220139f5e171258c0 (diff)
chess-pos.el: Collapse two chess-pos-piece-p calls into one chess-pos-piece call.
Unexpected but true, this increases performance noticeably.
Diffstat (limited to 'chess-pos.el')
-rw-r--r--chess-pos.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/chess-pos.el b/chess-pos.el
index 92e3d6c..131245e 100644
--- a/chess-pos.el
+++ b/chess-pos.el
@@ -904,12 +904,12 @@ If NO-CASTLING is non-nil, do not consider castling moves."
;; up the current file
(setq pos (chess-next-index target dir))
(while pos
- (if (chess-pos-piece-p position pos piece)
- (progn
- (chess--add-candidate pos)
- (setq pos nil))
- (setq pos (and (chess-pos-piece-p position pos ? )
- (chess-next-index pos dir)))))
+ (let ((pos-piece (chess-pos-piece position pos)))
+ (if (eq pos-piece piece)
+ (progn
+ (chess--add-candidate pos)
+ (setq pos nil))
+ (setq pos (and (eq pos-piece ? ) (chess-next-index pos dir))))))
;; test whether the rook can move to the target by castling
(if (and (= test-piece ?R) (not no-castling))