1
1

Speeding up the finding of the longest filename in the current folder.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5356 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Benno Schulenberg 2015-08-13 18:22:29 +00:00
родитель 677e9474f7
Коммит 8a058d1f9a
2 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -1,6 +1,9 @@
2015-08-13 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_find_bracket): Remove mistaken comparison between
pointer and literal character. Found with cppcheck.
* src/browser.c (browser_init): Speed up the finding of the longest
filename: don't limit the value to that of COLS all the time, as this
is done later anyway, and don't bother skipping the dot entry.
2015-08-12 Benno Schulenberg <bensberg@justemail.net>
* src/chars.c: UTF-8 is a stateless encoding, so there is no need to

Просмотреть файл

@ -436,29 +436,30 @@ void browser_init(const char *path, DIR *dir)
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
/* Set longest to zero, just before we initialize it. */
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t d_len;
size_t name_len = strlenpt(nextdir->d_name);
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
d_len = strlenpt(nextdir->d_name);
if (d_len > longest)
longest = (d_len > COLS) ? COLS : d_len;
if (name_len > longest)
longest = name_len;
i++;
}
rewinddir(dir);
/* Put 10 columns' worth of blank space between columns of filenames
/* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
/* Make sure longest is between 15 and COLS. */
if (longest < 15)
longest = 15;
if (longest > COLS)
longest = COLS;
rewinddir(dir);
if (filelist != NULL)
free_chararray(filelist, filelist_len);
@ -486,12 +487,6 @@ void browser_init(const char *path, DIR *dir)
closedir(dir);
/* Make sure longest is between 15 and COLS. */
if (longest < 15)
longest = 15;
if (longest > COLS)
longest = COLS;
/* Set width to zero, just before we initialize it. */
width = 0;