[jruby-joni] 29/279: Some character length routines micro-optz.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:26:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 346f661ab549ec841003908e2c848233f0785b76
Author: Marcin Mielżyński <lopx at gazeta.pl>
Date:   Tue Aug 26 22:24:36 2008 +0000

    Some character length routines micro-optz.
    
    git-svn-id: http://svn.codehaus.org/jruby/joni/trunk@7553 961051c9-f516-0410-bf72-c9f7e237a7b7
---
 src/org/joni/encoding/MultiByteEncoding.java       | 28 +++++++++++-----------
 .../joni/encoding/specific/GB18030Encoding.java    | 14 +++++------
 src/org/joni/encoding/specific/GBKEncoding.java    |  2 +-
 src/org/joni/encoding/specific/KOI8REncoding.java  |  2 +-
 src/org/joni/encoding/specific/KOI8UEncoding.java  |  2 +-
 src/org/joni/encoding/specific/SJISEncoding.java   |  2 +-
 6 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/org/joni/encoding/MultiByteEncoding.java b/src/org/joni/encoding/MultiByteEncoding.java
index 1ee2b2a..20c2dd6 100644
--- a/src/org/joni/encoding/MultiByteEncoding.java
+++ b/src/org/joni/encoding/MultiByteEncoding.java
@@ -48,7 +48,7 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }
 
     protected final int safeLengthForUptoFour(byte[]bytes, int p ,int end) {
-        int b = bytes[p++] & 0xff;
+        int b = bytes[p] & 0xff;
         int s = TransZero[b];
         if (s < 0) {
             if (s == A) return 1;
@@ -58,8 +58,8 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }
 
     private int lengthForTwoUptoFour(byte[]bytes, int p, int end, int b, int s) {
-        if (p == end) return -(EncLen[b] - 1);
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -(EncLen[b] - 1);
+        s = Trans[s][bytes[p] & 0xff];
         if (s < 0) {
             if (s == A) return 2;
             throw IllegalCharacterException.INSTANCE;
@@ -68,20 +68,20 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }
 
     private int lengthForThreeUptoFour(byte[]bytes, int p, int end, int b, int s) {
-        if (p == end) return -(EncLen[b] - 2);
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -(EncLen[b] - 2);
+        s = Trans[s][bytes[p] & 0xff];
         if (s < 0) {
             if (s == A) return 3;
             throw IllegalCharacterException.INSTANCE;
         }
-        if (p == end) return -(EncLen[b] - 3);
+        if (++p == end) return -(EncLen[b] - 3);
         s = Trans[s][bytes[p] & 0xff];
         if (s == A) return 4;
         throw IllegalCharacterException.INSTANCE;  
     }
 
     protected final int safeLengthForUptoThree(byte[]bytes, int p, int end) {
-        int b = bytes[p++] & 0xff;
+        int b = bytes[p] & 0xff;
         int s = TransZero[b];
         if (s < 0) {
             if (s == A) return 1;
@@ -91,8 +91,8 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }
 
     private int lengthForTwoUptoThree(byte[]bytes, int p, int end, int b, int s) {
-        if (p == end) return -(EncLen[b] - 1);
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -(EncLen[b] - 1);
+        s = Trans[s][bytes[p] & 0xff];
         if (s < 0) {
             if (s == A) return 2;
             throw IllegalCharacterException.INSTANCE;
@@ -101,14 +101,14 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }
 
     private int lengthForThree(byte[]bytes, int p, int end, int b, int s) {
-        if (p == end) return -(EncLen[b] - 2);
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -(EncLen[b] - 2);
+        s = Trans[s][bytes[p] & 0xff];
         if (s == A) return 3;
         throw IllegalCharacterException.INSTANCE;
     }     
 
     protected final int safeLengthForUptoTwo(byte[]bytes, int p, int end) {
-        int b = bytes[p++] & 0xff;
+        int b = bytes[p] & 0xff;
         int s = TransZero[b];
         
         if (s < 0) {
@@ -119,8 +119,8 @@ public abstract class MultiByteEncoding extends AbstractEncoding {
     }    
 
     private int lengthForTwo(byte[]bytes, int p, int end, int b, int s) {
-        if (p == end) return -(EncLen[b] - 1);
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -(EncLen[b] - 1);
+        s = Trans[s][bytes[p] & 0xff];
         if (s == A) return 2;
         throw IllegalCharacterException.INSTANCE;
     }
diff --git a/src/org/joni/encoding/specific/GB18030Encoding.java b/src/org/joni/encoding/specific/GB18030Encoding.java
index 105523d..44086bc 100644
--- a/src/org/joni/encoding/specific/GB18030Encoding.java
+++ b/src/org/joni/encoding/specific/GB18030Encoding.java
@@ -37,14 +37,14 @@ public final class GB18030Encoding extends MultiByteEncoding  {
 
     @Override
     public int length(byte[]bytes, int p, int end) {
-        if (Config.VANILLA){
+        if (Config.VANILLA) {
             if (GB18030_MAP[bytes[p] & 0xff] != CM) return 1;
             int c = GB18030_MAP[bytes[p + 1] & 0xff];
             if (c == C4) return 4;
             if (c == C1) return 1; /* illegal sequence */
             return 2;
         } else {
-            int s = TransZero[bytes[p++] & 0xff];
+            int s = TransZero[bytes[p] & 0xff];
             if (s < 0) {
                 if (s == A) return 1;
                 throw IllegalCharacterException.INSTANCE;
@@ -54,8 +54,8 @@ public final class GB18030Encoding extends MultiByteEncoding  {
     }
 
     private int lengthForTwoUptoFour(byte[]bytes, int p, int end, int s) {
-        if (p == end) return -1;
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -1;
+        s = Trans[s][bytes[p] & 0xff];
         if (s < 0) {
             if (s == A) return 2;
             throw IllegalCharacterException.INSTANCE;
@@ -64,13 +64,13 @@ public final class GB18030Encoding extends MultiByteEncoding  {
     }
 
     private int lengthForThreeUptoFour(byte[]bytes, int p, int end, int s) {
-        if (p == end) return -2;
-        s = Trans[s][bytes[p++] & 0xff];
+        if (++p == end) return -2;
+        s = Trans[s][bytes[p] & 0xff];
         if (s < 0) {
             if (s == A) return 3;
             throw IllegalCharacterException.INSTANCE;
         }
-        if (p == end) return -1;
+        if (++p == end) return -1;
         s = Trans[s][bytes[p] & 0xff];
         if (s == A) return 4;
         throw IllegalCharacterException.INSTANCE;  
diff --git a/src/org/joni/encoding/specific/GBKEncoding.java b/src/org/joni/encoding/specific/GBKEncoding.java
index 4c3bf1f..a976761 100644
--- a/src/org/joni/encoding/specific/GBKEncoding.java
+++ b/src/org/joni/encoding/specific/GBKEncoding.java
@@ -36,7 +36,7 @@ public final class GBKEncoding extends CanBeTrailTableEncoding {
 
     @Override
     public int length(byte[]bytes, int p, int end) {
-        if (Config.VANILLA){
+        if (Config.VANILLA) {
             return length(bytes[p]);
         } else {
             return safeLengthForUptoTwo(bytes, p, end);
diff --git a/src/org/joni/encoding/specific/KOI8REncoding.java b/src/org/joni/encoding/specific/KOI8REncoding.java
index d870698..a1c3de3 100644
--- a/src/org/joni/encoding/specific/KOI8REncoding.java
+++ b/src/org/joni/encoding/specific/KOI8REncoding.java
@@ -22,7 +22,7 @@ package org.joni.encoding.specific;
 import org.joni.IntHolder;
 import org.joni.encoding.CaseFoldMapEncoding;
 
-final public class KOI8REncoding extends CaseFoldMapEncoding  {
+final public class KOI8REncoding extends CaseFoldMapEncoding {
 
     protected KOI8REncoding() {
         super(KOI8R_CtypeTable, KOI8R_ToLowerCaseTable, KOI8R_CaseFoldMap, false);
diff --git a/src/org/joni/encoding/specific/KOI8UEncoding.java b/src/org/joni/encoding/specific/KOI8UEncoding.java
index 40399b3..0a9db99 100644
--- a/src/org/joni/encoding/specific/KOI8UEncoding.java
+++ b/src/org/joni/encoding/specific/KOI8UEncoding.java
@@ -22,7 +22,7 @@ package org.joni.encoding.specific;
 import org.joni.IntHolder;
 import org.joni.encoding.CaseFoldMapEncoding;
 
-final public class KOI8UEncoding extends CaseFoldMapEncoding  {
+final public class KOI8UEncoding extends CaseFoldMapEncoding {
 
     protected KOI8UEncoding() {
         super(KOI8U_CtypeTable, KOI8U_ToLowerCaseTable, KOI8U_CaseFoldMap, false);
diff --git a/src/org/joni/encoding/specific/SJISEncoding.java b/src/org/joni/encoding/specific/SJISEncoding.java
index b22c3fb..faca0cc 100644
--- a/src/org/joni/encoding/specific/SJISEncoding.java
+++ b/src/org/joni/encoding/specific/SJISEncoding.java
@@ -28,7 +28,7 @@ import org.joni.exception.ErrorMessages;
 import org.joni.exception.InternalException;
 import org.joni.util.BytesHash;
 
-public final class SJISEncoding extends CanBeTrailTableEncoding  {
+public final class SJISEncoding extends CanBeTrailTableEncoding {
 
     protected SJISEncoding() {
         super(1, 2, SjisEncLen, SjisTrans, ASCIIEncoding.AsciiCtypeTable, SJIS_CAN_BE_TRAIL_TABLE);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list