Results in even less memory usage. The names are appended one after another.
The offsets are reset when the location of the memory changes die to realloc().
Other changes:
1. Use a debug mode print to measure time.
2. Remove redundant prefix when printing pointers in debug mode.
nnn has been using `struct entry` to hold both file name as well as file info.
The design forces file names to be copied in the following cases:
- swaps during file sort (nnn uses quicksort) applied after all the matching
files are read (in no particular order; good old readdir()) into memory.
- swaps during manual filtering. nnn moves non-matching entries below so they
are not encountered twice resulting in fast filtering.
There were scopes for _massive_ improvements in this area. So I did what had to
be done - decouple the file names from `struct entry` and use a separate struct
to hold the names with the indices set when the files are added by opendir().
There was a hidden problem to this approach - nnn uses realloc() to allocate
memory for file information and realloc() may move the original pointer in mem
when it can't fit the new memory to the earlier pointer. To handle that the new
algorithm tracks the change in memory location and re-adjusts the existing dir
entry names when that happens; this too, without any copying!
Though the results seem pretty clean from a theoretical point of view and early
tests, we may uncover some bugs. However, the speed is just mind-blowing!
And the binary size remains the same too!!!
* Prevent nnn from waiting on open file process
* Add env var flag to not wait for child process when opening file
* Set nowait flag once to skip bit-or every time we open a file
* Add documentation for NNN_NOWAIT
Check if the number of columns needed to print name exceeds the number of cols.
If it does, split the name str at the max number of columns available for name.
Conversion to wide char ensures the split is done at a valid codepoint.
The current patch adds some optimization as well:
- No more copying to an intermediate (global) string.
- If the name is shortened, escape chars are replaced only till the terminator.