Browse Source

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.
pull/360/head^2
Mislav Marohnić 10 years ago
parent
commit
89d4e8a0e0
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      libexec/rbenv-rehash

+ 9
- 1
libexec/rbenv-rehash View File

@ -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…
Cancel
Save