cli/internal/build/build.go
Mislav Marohnić 8741b648a6
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.
2023-05-26 16:38:13 +02:00

27 lines
767 B
Go

package build
import (
"os"
"runtime/debug"
)
// Version is dynamically set by the toolchain or overridden by the Makefile.
var Version = "DEV"
// Date is dynamically set at build time in the Makefile.
var Date = "" // YYYY-MM-DD
func init() {
if Version == "DEV" {
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
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")
}