From 163a3be18b92b9deb0a99795fab7b6ca819f1ecc Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 4 Apr 2016 17:31:32 -0400 Subject: [PATCH] upload: short circuit when nothing is pending When nothing is pending, most of this code is already short-circuited. Hoist the single check up to make this more obvious/slightly faster. Change-Id: Iec3a7e08eacd23a7c5f964900d5776bf5252c804 --- subcmds/upload.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/subcmds/upload.py b/subcmds/upload.py index 4b05f1e8..1172dadc 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -454,7 +454,11 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ if avail: pending.append((project, avail)) - if pending and (not opt.bypass_hooks): + if not pending: + print("no branches ready for upload", file=sys.stderr) + return + + if not opt.bypass_hooks: hook = RepoHook('pre-upload', self.manifest.repo_hooks_project, self.manifest.topdir, self.manifest.manifestProject.GetRemote('origin').url, @@ -474,9 +478,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ cc = _SplitEmails(opt.cc) people = (reviewers, cc) - if not pending: - print("no branches ready for upload", file=sys.stderr) - elif len(pending) == 1 and len(pending[0][1]) == 1: + if len(pending) == 1 and len(pending[0][1]) == 1: self._SingleBranch(opt, pending[0][1][0], people) else: self._MultipleBranches(opt, pending, people)