1) Got rid of useless call to `cat`, much better to simply use sed with
file as argument.
2) Got rid of `sort -u`. There is no need to sort the list.
Additionally, the list `pyenv.d/rehash/conda.d/default.list` only has
unique entries, and even if you have duplicate entries, the function
will still work. --> No need for sort nor unique.
3) Further improvement is simple, save a cached
cleaned-list-v1.0 in `conda.d` and simple read from that file instead of
doing `sed`, which must be a more expensive operation than simply
reading from file.
I was doing some debugging with PYENV_DEBUG=1 and noticed that a lot of
work was being done in conda.bash, even though I had not installed any
conda versions like `mambaforge`.
The solution is pretty simple, put all the code inside an if-block.
This aligns with what @varikin found in his pull request #3037
Additionally, I have refactored the code slightly for readability
(created function `build_conda_exclusion_list`), and added comments
which should make it easier to understand what's going on.
This commit simplifies debugging and should reduce the execution time of
```bash
eval "$(pyenv init -)"
```
slightly.
According to the POSIX spec, an unescaped backslash not followed by
an escapable character is undefined behavior,
and it has become an error in GNU grep 3.8 (2022-09-02).
The performance issue must be caused by too many I/O requests to
`conda.txt` from fgrep. This inline expansion should work to reduce # of
read to the `conda.txt`.
original performance:
```
% git rev-parse HEAD
4f76be6a129a7281a41780783eefdab3ec472a40
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.05s user 0.02s system 76% cpu 0.089 total
```
previous commit: ==> 4x slower than original
```
% git rev-parse HEAD
4469d51ef7bb3e2907f5a363bb97d92896628527
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.06s user 0.03s system 25% cpu 0.358 total
```
with this workaround: ==> almost same as original
```
% git rev-parse HEAD
3ffe91bdbc69220eaecf6e2088229cc27366c3f3
% time bash -c 'pyenv rehash'
bash -c 'pyenv rehash' 0.05s user 0.00s system 68% cpu 0.082 total
```