BatchRefUpdate: Consistent switch branches in ref update

The expression RefUpdate ru = newUpdate(cmd) is eagerly evaluated before the switch statement.
But it is not used in some switch cases and thus is calculated uselessly.

Move expression evaluation to the switch case where it is actually used.
After such a move, several cases became identical and thus were squashed.

Change-Id: Ifd1976f1c28378e092fb24d7ca9c415cba49f07f
This commit is contained in:
Sergey 2022-12-07 15:49:47 +04:00 committed by Matthias Sohn
parent 2b21d9bbb6
commit ec7c61eac3
1 changed files with 1 additions and 4 deletions

View File

@ -498,17 +498,14 @@ public void execute(RevWalk walk, ProgressMonitor monitor,
try {
if (cmd.getResult() == NOT_ATTEMPTED) {
cmd.updateType(walk);
RefUpdate ru = newUpdate(cmd);
switch (cmd.getType()) {
case DELETE:
// Performed in the first phase
break;
case UPDATE:
case UPDATE_NONFASTFORWARD:
RefUpdate ruu = newUpdate(cmd);
cmd.setResult(ruu.update(walk));
break;
case CREATE:
RefUpdate ru = newUpdate(cmd);
cmd.setResult(ru.update(walk));
break;
}