From 03eeed5885ae8ed45357412f6c2ac5cad1683e30 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 10 Sep 2010 11:51:40 +0200 Subject: [PATCH] mq_nodup(): Merge tags when removing moves. Clean up. --- mq.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mq.h b/mq.h index 8f483df..7363f99 100644 --- a/mq.h +++ b/mq.h @@ -61,10 +61,15 @@ mq_append(struct move_queue *qd, struct move_queue *qs) static inline void mq_nodup(struct move_queue *q) { - if ((q->moves > 1 && q->move[q->moves - 2] == q->move[q->moves - 1]) - || (q->moves > 2 && q->move[q->moves - 3] == q->move[q->moves - 1]) - || (q->moves > 3 && q->move[q->moves - 4] == q->move[q->moves - 1])) - q->moves--; + for (unsigned int i = 1; i < 4; i++) { + if (q->moves <= i) + return; + if (q->move[q->moves - 1 - i] == q->move[q->moves - 1]) { + q->tag[q->moves - 1 - i] |= q->tag[q->moves - 1]; + q->moves--; + return; + } + } } static inline void -- 2.11.4.GIT