]> source.dussan.org Git - jgit.git/commitdiff
Using for-each loop in jdt 82/158482/2
authorLars Vogel <Lars.Vogel@vogella.com>
Thu, 27 Feb 2020 10:05:23 +0000 (11:05 +0100)
committerLars Vogel <Lars.Vogel@vogella.com>
Fri, 28 Feb 2020 07:39:12 +0000 (02:39 -0500)
Running the JDT cleanup action for using a for-each loop on jgit

Change-Id: Ie724d8bbdff786ab0167089e90a9914a8135103c
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaIndex.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/PatternMatchRevFilter.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
org.eclipse.jgit/src/org/eclipse/jgit/util/QuotedString.java
org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java

index b722fbe9d112582d6eea43f2fb7d444a7ee628fe..6678af163a85327f0951d3c10f51693845f7f4e5 100644 (file)
@@ -338,8 +338,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                                                steps, false);
                        }
                        checkSteps(steps);
-                       for (int i = 0; i < steps.size(); i++) {
-                               RebaseTodoLine step = steps.get(i);
+                       for (RebaseTodoLine step : steps) {
                                popSteps(1);
                                RebaseResult result = processStep(step, true);
                                if (result != null) {
index 3a6c413a02591de7bd97907fe839b415f63f1fc1..57b90e9668d84f6576ca1ef74b3e7ff89a26f46c 100644 (file)
@@ -380,8 +380,8 @@ public class FileNameMatcher {
         * @return a boolean.
         */
        public boolean canAppendMatch() {
-               for (int i = 0; i < heads.size(); i++) {
-                       if (heads.get(i) != LastHead.INSTANCE) {
+               for (Head head : heads) {
+                       if (head != LastHead.INSTANCE) {
                                return true;
                        }
                }
index 79eaea093aa1f66cded3c7619cd0d8343abf34ad..7ed5defbe476cee9e0a25a3a4a428e5044308b70 100644 (file)
@@ -122,8 +122,8 @@ public class DeltaIndex {
                // logic linear in the size of the input rather than quadratic.
                //
                int cnt = 0;
-               for (int i = 0; i < table.length; i++) {
-                       int h = table[i];
+               for (int element : table) {
+                       int h = element;
                        if (h == 0)
                                continue;
 
index 0d782e0a37e1f0cf990168b23bf77778b81528c8..efb5ee5e4d0c44fee0a47db8c261b8944110415a 100644 (file)
@@ -42,8 +42,8 @@ public abstract class PatternMatchRevFilter extends RevFilter {
        protected static final String forceToRaw(String patternText) {
                final byte[] b = Constants.encode(patternText);
                final StringBuilder needle = new StringBuilder(b.length);
-               for (int i = 0; i < b.length; i++)
-                       needle.append((char) (b[i] & 0xff));
+               for (byte element : b)
+                       needle.append((char) (element & 0xff));
                return needle.toString();
        }
 
index adc85a18e0a4e9f272b392fef71564fc3d90eccc..aec5b89c7e4a1980c5720f06bb4eb9ebc1053716 100644 (file)
@@ -423,8 +423,7 @@ abstract class HttpAuthMethod {
 
                private static String LHEX(byte[] bin) {
                        StringBuilder r = new StringBuilder(bin.length * 2);
-                       for (int i = 0; i < bin.length; i++) {
-                               byte b = bin[i];
+                       for (byte b : bin) {
                                r.append(LHEX[(b >>> 4) & 0x0f]);
                                r.append(LHEX[b & 0x0f]);
                        }
index 858d1f7b6a913b1e429b28857a1d67682306ef10..06520ec4ca61804c15f168821004b26ee33cb630 100644 (file)
@@ -303,8 +303,8 @@ public class URIish implements Serializable {
                        return null;
                ByteArrayOutputStream os = new ByteArrayOutputStream(s.length());
                byte[] bytes = s.getBytes(UTF_8);
-               for (int i = 0; i < bytes.length; ++i) {
-                       int b = bytes[i] & 0xFF;
+               for (byte c : bytes) {
+                       int b = c & 0xFF;
                        if (b <= 32 || (encodeNonAscii && b > 127) || b == '%'
                                        || (escapeReservedChars && reservedChars.get(b))) {
                                os.write('%');
index c45f0095d9061ec4ac9a446c4b1b79d7e8a3054c..493ca312d1fcc93fd8619bcbbd4f89b1dcda3f56 100644 (file)
@@ -243,8 +243,8 @@ public abstract class QuotedString {
                        final byte[] out = new byte[4 * in.length + 2];
                        int o = 0;
                        out[o++] = '"';
-                       for (int i = 0; i < in.length; i++) {
-                               final int c = in[i] & 0xff;
+                       for (byte element : in) {
+                               final int c = element & 0xff;
                                if (c < quote.length) {
                                        final byte style = quote[c];
                                        if (style == 0) {
index 669f73842790eb8a94f3bd031e6b9220112d4ac4..df9c6c78fe11592be91119bcaf409bc09c837051 100644 (file)
@@ -559,8 +559,8 @@ public final class RawParseUtils {
                }
                while (ptr < b.length - (headerName.length + 1)) {
                        boolean found = true;
-                       for (int i = 0; i < headerName.length; i++) {
-                               if (headerName[i] != b[ptr++]) {
+                       for (byte element : headerName) {
+                               if (element != b[ptr++]) {
                                        found = false;
                                        break;
                                }