mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Code refatoring
This commit is contained in:
parent
eeb4b933b0
commit
af8c52b026
20
src/nnn.c
20
src/nnn.c
|
@ -1420,23 +1420,29 @@ static int nextsel(int *presel)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void swap_ent(int id1, int id2)
|
||||||
|
{
|
||||||
|
static struct entry _dent, *pdent1, *pdent2;;
|
||||||
|
|
||||||
|
pdent1 = &dents[id1];
|
||||||
|
pdent2 = &dents[id2];
|
||||||
|
|
||||||
|
*(&_dent) = *pdent1;
|
||||||
|
*pdent1 = *pdent2;
|
||||||
|
*pdent2 = *(&_dent);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move non-matching entries to the end
|
* Move non-matching entries to the end
|
||||||
*/
|
*/
|
||||||
static int fill(char *fltr, regex_t *re)
|
static int fill(char *fltr, regex_t *re)
|
||||||
{
|
{
|
||||||
static int count;
|
static int count;
|
||||||
static struct entry _dent, *pdent1, *pdent2;
|
|
||||||
|
|
||||||
for (count = 0; count < ndents; ++count) {
|
for (count = 0; count < ndents; ++count) {
|
||||||
if (filterfn(re, dents[count].name, fltr) == 0) {
|
if (filterfn(re, dents[count].name, fltr) == 0) {
|
||||||
if (count != --ndents) {
|
if (count != --ndents) {
|
||||||
pdent1 = &dents[count];
|
swap_ent(count, ndents);
|
||||||
pdent2 = &dents[ndents];
|
|
||||||
|
|
||||||
*(&_dent) = *pdent1;
|
|
||||||
*pdent1 = *pdent2;
|
|
||||||
*pdent2 = *(&_dent);
|
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue