Skip to content

Commit a2d7807

Browse files
committed
cmd/docker: small performance optimizations for running hooks
Order conditions to check for lightweight ones first; - checck if the command is not nil - dockerCli.Out().IsTerminal() is a lightweight getter - dockerCli.HooksEnabled() checks for env-vars, parses booleans, and reading the CLI config-file Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent ea1f10b commit a2d7807

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cmd/docker/docker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
446446
if err != nil || pluginmanager.IsPluginCommand(ccmd) {
447447
err := tryPluginRun(ctx, dockerCli, cmd, args[0], envs)
448448
if err == nil {
449-
if dockerCli.HooksEnabled() && dockerCli.Out().IsTerminal() && ccmd != nil {
449+
if ccmd != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() {
450450
pluginmanager.RunPluginHooks(ctx, dockerCli, cmd, ccmd, args)
451451
}
452452
return nil
@@ -471,7 +471,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
471471

472472
// If the command is being executed in an interactive terminal
473473
// and hook are enabled, run the plugin hooks.
474-
if dockerCli.HooksEnabled() && dockerCli.Out().IsTerminal() && subCommand != nil {
474+
if subCommand != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() {
475475
var errMessage string
476476
if err != nil {
477477
errMessage = err.Error()

0 commit comments

Comments
 (0)