mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Speed up rehash process when there are many Ruby versions
On my system that has 25 versions under rbenv, this speeds up rehash almost 3-fold: - before: 391 ms - after: 134 ms This is achieved by removing duplicate names of executables before registering them as shims. Since most Rubies will share a lot of the same executable names ("ruby", "rake", "bundle", ...), this is a considerable reduction in number of shims registered.
This commit is contained in:
parent
a8df5d587c
commit
89d4e8a0e0
1 changed files with 9 additions and 1 deletions
|
@ -79,6 +79,14 @@ remove_outdated_shims() {
|
|||
done
|
||||
}
|
||||
|
||||
# List basenames of executables for every Ruby version
|
||||
list_executable_names() {
|
||||
local file
|
||||
for file in "$RBENV_ROOT"/versions/*/bin/*; do
|
||||
echo "${file##*/}"
|
||||
done
|
||||
}
|
||||
|
||||
# The basename of each argument passed to `make_shims` will be
|
||||
# registered for installation as a shim. In this way, plugins may call
|
||||
# `make_shims` with a glob to register many shims at once.
|
||||
|
@ -136,7 +144,7 @@ shopt -s nullglob
|
|||
# executables.
|
||||
create_prototype_shim
|
||||
remove_outdated_shims
|
||||
make_shims ../versions/*/bin/*
|
||||
make_shims $(list_executable_names | sort -u)
|
||||
|
||||
|
||||
# Allow plugins to register shims.
|
||||
|
|
Loading…
Reference in a new issue