[JGIT PATCH 2/6] Simplify RawParseUtils next and nextLF loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We always need ptr + 1 after we read the current position,
so we might as well do the much more common foo[ptr++]. A
good JIT would be more likely to optimize this case over
the weird else branch we had.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/util/RawParseUtils.java   |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
index 10c2239..5a40911 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java
@@ -221,10 +221,8 @@ public static final int parseTimeZoneOffset(final byte[] b, int ptr) {
 	public static final int next(final byte[] b, int ptr, final char chrA) {
 		final int sz = b.length;
 		while (ptr < sz) {
-			if (b[ptr] == chrA)
-				return ptr + 1;
-			else
-				ptr++;
+			if (b[ptr++] == chrA)
+				return ptr;
 		}
 		return ptr;
 	}
@@ -260,11 +258,9 @@ public static final int nextLF(final byte[] b, int ptr) {
 	public static final int nextLF(final byte[] b, int ptr, final char chrA) {
 		final int sz = b.length;
 		while (ptr < sz) {
-			final byte c = b[ptr];
+			final byte c = b[ptr++];
 			if (c == chrA || c == '\n')
-				return ptr + 1;
-			else
-				ptr++;
+				return ptr;
 		}
 		return ptr;
 	}
-- 
1.6.1.rc2.299.gead4c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux