Simplify cg_mark_range

This commit is contained in:
Bert Münnich 2018-06-09 12:17:03 +02:00
parent a1165df878
commit 1892ed9fd7

View File

@ -216,30 +216,19 @@ bool cg_reverse_marks(arg_t _)
bool cg_mark_range(arg_t _) bool cg_mark_range(arg_t _)
{ {
int i, from, to; int i, d = fileidx < markidx ? 1 : -1;
int flag = files[markidx].flags & FF_MARK;
int oldmarkcnt = markcnt;
from = markidx; for (i = fileidx; i != markidx; i += d) {
to = fileidx; if ((files[i].flags & FF_MARK) ^ flag) {
if (fileidx < markidx) { files[i].flags = (files[i].flags & ~FF_MARK) | flag;
from = fileidx; markcnt += flag ? 1 : -1;
to = markidx;
}
for (i = from; i <= to; i++) {
if (files[markidx].flags & FF_MARK) {
if (!(files[i].flags & FF_MARK)) {
files[i].flags |= FF_MARK;
markcnt += 1;
}
} else {
if (files[i].flags & FF_MARK) {
files[i].flags &= ~FF_MARK;
markcnt -= 1;
}
}
if (mode == MODE_THUMB) if (mode == MODE_THUMB)
tns_mark(&tns, i, !!(files[i].flags & FF_MARK)); tns_mark(&tns, i, !!flag);
} }
return true; }
return markcnt != oldmarkcnt;
} }
bool cg_unmark_all(arg_t _) bool cg_unmark_all(arg_t _)