]> source.dussan.org Git - jgit.git/commitdiff
Fix a complicated multi level nested if block structure to use a single level with... 67/3467/3
authorKetan Padegaonkar <KetanPadegaonkar@gmail.com>
Thu, 19 May 2011 07:43:18 +0000 (13:13 +0530)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 31 May 2011 16:15:28 +0000 (09:15 -0700)
Change-Id: I3f116f37045e83aba5c80d45b987ab075502dcc6

org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

index 8fe7b2aa519b2aeb4dde98ba80e9d859c6e20479..8534724cbbac85bb1ca6629cc5d8a6042c482369 100644 (file)
@@ -202,43 +202,42 @@ public class URIish implements Serializable {
                if (matcher.matches()) {
                        scheme = matcher.group(1);
                        path = cleanLeadingSlashes(matcher.group(2), scheme);
-               } else {
-                       matcher = FULL_URI.matcher(s);
-                       if (matcher.matches()) {
-                               scheme = matcher.group(1);
-                               user = matcher.group(2);
-                               pass = matcher.group(3);
-                               host = matcher.group(4);
-                               if (matcher.group(5) != null)
-                                       port = Integer.parseInt(matcher.group(5));
-                               path = cleanLeadingSlashes(
-                                               n2e(matcher.group(6)) + n2e(matcher.group(7)),
-                                               scheme);
-                       } else {
-                               matcher = RELATIVE_SCP_URI.matcher(s);
-                               if (matcher.matches()) {
-                                       user = matcher.group(1);
-                                       pass = matcher.group(2);
-                                       host = matcher.group(3);
-                                       path = matcher.group(4);
-                               } else {
-                                       matcher = ABSOLUTE_SCP_URI.matcher(s);
-                                       if (matcher.matches()) {
-                                               user = matcher.group(1);
-                                               pass = matcher.group(2);
-                                               host = matcher.group(3);
-                                               path = matcher.group(4);
-                                       } else {
-                                               matcher = LOCAL_FILE.matcher(s);
-                                               if (matcher.matches()) {
-                                                       path = matcher.group(1);
-                                               } else
-                                                       throw new URISyntaxException(s,
-                                                                       JGitText.get().cannotParseGitURIish);
-                                       }
-                               }
-                       }
+                       return;
+               }
+               matcher = FULL_URI.matcher(s);
+               if (matcher.matches()) {
+                       scheme = matcher.group(1);
+                       user = matcher.group(2);
+                       pass = matcher.group(3);
+                       host = matcher.group(4);
+                       if (matcher.group(5) != null)
+                               port = Integer.parseInt(matcher.group(5));
+                       path = cleanLeadingSlashes(
+                                       n2e(matcher.group(6)) + n2e(matcher.group(7)), scheme);
+                       return;
+               }
+               matcher = RELATIVE_SCP_URI.matcher(s);
+               if (matcher.matches()) {
+                       user = matcher.group(1);
+                       pass = matcher.group(2);
+                       host = matcher.group(3);
+                       path = matcher.group(4);
+                       return;
+               }
+               matcher = ABSOLUTE_SCP_URI.matcher(s);
+               if (matcher.matches()) {
+                       user = matcher.group(1);
+                       pass = matcher.group(2);
+                       host = matcher.group(3);
+                       path = matcher.group(4);
+                       return;
+               }
+               matcher = LOCAL_FILE.matcher(s);
+               if (matcher.matches()) {
+                       path = matcher.group(1);
+                       return;
                }
+               throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
        }
 
        private String n2e(String s) {