Speed up brew --prefix
Move --prefix, --cellar to the top of brew.sh. Timings on master: brew --prefix > /dev/null 0.05s user 0.03s system 46% cpu 0.165 total brew --prefix > /dev/null 0.05s user 0.04s system 63% cpu 0.131 total brew --prefix > /dev/null 0.04s user 0.03s system 72% cpu 0.104 total brew --prefix > /dev/null 0.04s user 0.03s system 87% cpu 0.080 total brew --prefix > /dev/null 0.04s user 0.03s system 81% cpu 0.080 total brew --prefix > /dev/null 0.04s user 0.03s system 84% cpu 0.075 total brew --prefix > /dev/null 0.04s user 0.03s system 83% cpu 0.080 total brew --prefix > /dev/null 0.04s user 0.02s system 84% cpu 0.072 total brew --prefix > /dev/null 0.04s user 0.03s system 86% cpu 0.072 total brew --prefix > /dev/null 0.04s user 0.03s system 82% cpu 0.075 total brew --prefix > /dev/null 0.04s user 0.03s system 85% cpu 0.072 total brew --prefix > /dev/null 0.04s user 0.03s system 84% cpu 0.076 total brew --prefix > /dev/null 0.04s user 0.03s system 85% cpu 0.074 total brew --prefix > /dev/null 0.03s user 0.03s system 83% cpu 0.073 total brew --prefix > /dev/null 0.04s user 0.02s system 83% cpu 0.072 total brew --prefix > /dev/null 0.03s user 0.03s system 86% cpu 0.068 total brew --prefix > /dev/null 0.04s user 0.03s system 82% cpu 0.080 total brew --prefix > /dev/null 0.04s user 0.03s system 84% cpu 0.079 total brew --prefix > /dev/null 0.04s user 0.02s system 83% cpu 0.070 total brew --prefix > /dev/null 0.03s user 0.03s system 84% cpu 0.072 total With the patch applied: brew --prefix > /dev/null 0.02s user 0.02s system 24% cpu 0.157 total brew --prefix > /dev/null 0.02s user 0.03s system 53% cpu 0.078 total brew --prefix > /dev/null 0.02s user 0.02s system 64% cpu 0.056 total brew --prefix > /dev/null 0.02s user 0.03s system 74% cpu 0.065 total brew --prefix > /dev/null 0.01s user 0.02s system 73% cpu 0.049 total brew --prefix > /dev/null 0.01s user 0.02s system 77% cpu 0.050 total brew --prefix > /dev/null 0.01s user 0.02s system 64% cpu 0.054 total brew --prefix > /dev/null 0.01s user 0.02s system 77% cpu 0.049 total brew --prefix > /dev/null 0.01s user 0.02s system 56% cpu 0.061 total brew --prefix > /dev/null 0.02s user 0.02s system 66% cpu 0.060 total brew --prefix > /dev/null 0.01s user 0.02s system 62% cpu 0.057 total brew --prefix > /dev/null 0.01s user 0.02s system 71% cpu 0.052 total brew --prefix > /dev/null 0.02s user 0.03s system 67% cpu 0.063 total brew --prefix > /dev/null 0.01s user 0.02s system 70% cpu 0.042 total brew --prefix > /dev/null 0.02s user 0.02s system 68% cpu 0.056 total brew --prefix > /dev/null 0.01s user 0.02s system 73% cpu 0.049 total brew --prefix > /dev/null 0.01s user 0.02s system 62% cpu 0.058 total brew --prefix > /dev/null 0.02s user 0.02s system 67% cpu 0.058 total brew --prefix > /dev/null 0.01s user 0.02s system 73% cpu 0.043 total brew --prefix > /dev/null 0.01s user 0.02s system 65% cpu 0.055 total
This commit is contained in:
parent
aa8eb21b8c
commit
be1764c0a5
@ -1,3 +1,24 @@
|
|||||||
|
# Force UTF-8 to avoid encoding issues for users with broken locale settings.
|
||||||
|
if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]]
|
||||||
|
then
|
||||||
|
export LC_ALL="en_US.UTF-8"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local
|
||||||
|
# for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY.
|
||||||
|
if [[ -d "$HOMEBREW_REPOSITORY/Cellar" ]]
|
||||||
|
then
|
||||||
|
HOMEBREW_CELLAR="$HOMEBREW_REPOSITORY/Cellar"
|
||||||
|
else
|
||||||
|
HOMEBREW_CELLAR="$HOMEBREW_PREFIX/Cellar"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$*" in
|
||||||
|
--prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;;
|
||||||
|
--cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;;
|
||||||
|
--repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbrev=7 2>/dev/null)"
|
HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbrev=7 2>/dev/null)"
|
||||||
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
|
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
|
||||||
if [[ -z "$HOMEBREW_VERSION" ]]
|
if [[ -z "$HOMEBREW_VERSION" ]]
|
||||||
@ -42,27 +63,6 @@ git() {
|
|||||||
"$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" "$@"
|
"$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Force UTF-8 to avoid encoding issues for users with broken locale settings.
|
|
||||||
if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]]
|
|
||||||
then
|
|
||||||
export LC_ALL="en_US.UTF-8"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local
|
|
||||||
# for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY.
|
|
||||||
if [[ -d "$HOMEBREW_REPOSITORY/Cellar" ]]
|
|
||||||
then
|
|
||||||
HOMEBREW_CELLAR="$HOMEBREW_REPOSITORY/Cellar"
|
|
||||||
else
|
|
||||||
HOMEBREW_CELLAR="$HOMEBREW_PREFIX/Cellar"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$*" in
|
|
||||||
--prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;;
|
|
||||||
--cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;;
|
|
||||||
--repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]]
|
if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]]
|
||||||
then
|
then
|
||||||
# it may work, but I only see pain this route and don't want to support it
|
# it may work, but I only see pain this route and don't want to support it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user