Speed up gh start up time (#7487)

The tcell library has an `init()` block where it performs some very expensive
indexing that takes 30-40 ms on my machine. This results in fixed overhead for
every gh invocation, even for commands that don't use tcell at all.

This sets an environment variable that instructs tcell to avoid doing that.
This commit is contained in:
Mislav Marohnić 2023-05-26 16:38:13 +02:00 committed by GitHub
parent b292dc43b2
commit 8741b648a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
package build
import (
"os"
"runtime/debug"
)
@ -16,4 +17,11 @@ func init() {
Version = info.Main.Version
}
}
// Signal the tcell library to skip its expensive `init` block. This saves 30-40ms in startup
// time for the gh process. The downside is that some Unicode glyphs from user-generated
// content might cause mis-alignment in tcell-enabled views.
//
// https://github.com/gdamore/tcell/commit/2f889d79bd61b1fd2f43372529975a65b792a7ae
_ = os.Setenv("TCELL_MINIMIZE", "1")
}