aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey <zakharovsergey1000@gmail.com>2022-12-07 15:49:47 +0400
committerMatthias Sohn <matthias.sohn@sap.com>2022-12-08 05:27:35 -0500
commitec7c61eac389d79ec3782989227309589e235e27 (patch)
tree3b66343566243a53697a09cc7f01f5d44746790d
parent2b21d9bbb6c98ff1b0f81df80d0726abf1d0727d (diff)
downloadjgit-ec7c61eac389d79ec3782989227309589e235e27.tar.gz
jgit-ec7c61eac389d79ec3782989227309589e235e27.zip
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
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java5
1 files changed, 1 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java
index ef1379a238..e2bebfefdb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java
@@ -498,17 +498,14 @@ public class BatchRefUpdate {
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;
}