@@ -80,13 +80,14 @@ public static byte[] fromAscii(final byte[] ascii) {
8080 if (isEmpty (ascii )) {
8181 return EMPTY_BYTE_ARRAY ;
8282 }
83+ final int asciiLength = ascii .length ;
8384 // get length/8 times bytes with 3 bit shifts to the right of the length
84- final byte [] l_raw = new byte [ascii . length >> 3 ];
85+ final byte [] l_raw = new byte [asciiLength >> 3 ];
8586 /*
8687 * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
8788 * loop.
8889 */
89- for (int ii = 0 , jj = ascii . length - 1 ; ii < l_raw .length ; ii ++, jj -= 8 ) {
90+ for (int ii = 0 , jj = asciiLength - 1 ; ii < l_raw .length ; ii ++, jj -= 8 ) {
9091 for (int bits = 0 ; bits < BITS .length ; ++bits ) {
9192 if (ascii [jj - bits ] == '1' ) {
9293 l_raw [ii ] |= BITS [bits ];
@@ -112,13 +113,14 @@ public static byte[] fromAscii(final char[] ascii) {
112113 if (ascii == null || ascii .length == 0 ) {
113114 return EMPTY_BYTE_ARRAY ;
114115 }
116+ final int asciiLength = ascii .length ;
115117 // get length/8 times bytes with 3 bit shifts to the right of the length
116- final byte [] l_raw = new byte [ascii . length >> 3 ];
118+ final byte [] l_raw = new byte [asciiLength >> 3 ];
117119 /*
118120 * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
119121 * loop.
120122 */
121- for (int ii = 0 , jj = ascii . length - 1 ; ii < l_raw .length ; ii ++, jj -= 8 ) {
123+ for (int ii = 0 , jj = asciiLength - 1 ; ii < l_raw .length ; ii ++, jj -= 8 ) {
122124 for (int bits = 0 ; bits < BITS .length ; ++bits ) {
123125 if (ascii [jj - bits ] == '1' ) {
124126 l_raw [ii ] |= BITS [bits ];
@@ -152,13 +154,14 @@ public static byte[] toAsciiBytes(final byte[] raw) {
152154 if (isEmpty (raw )) {
153155 return EMPTY_BYTE_ARRAY ;
154156 }
157+ final int rawLength = raw .length ;
155158 // get 8 times the bytes with 3 bit shifts to the left of the length
156- final byte [] l_ascii = new byte [raw . length << 3 ];
159+ final byte [] l_ascii = new byte [rawLength << 3 ];
157160 /*
158161 * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
159162 * loop.
160163 */
161- for (int ii = 0 , jj = l_ascii .length - 1 ; ii < raw . length ; ii ++, jj -= 8 ) {
164+ for (int ii = 0 , jj = l_ascii .length - 1 ; ii < rawLength ; ii ++, jj -= 8 ) {
162165 for (int bits = 0 ; bits < BITS .length ; ++bits ) {
163166 if ((raw [ii ] & BITS [bits ]) == 0 ) {
164167 l_ascii [jj - bits ] = '0' ;
@@ -182,13 +185,14 @@ public static char[] toAsciiChars(final byte[] raw) {
182185 if (isEmpty (raw )) {
183186 return EMPTY_CHAR_ARRAY ;
184187 }
188+ final int rawLength = raw .length ;
185189 // get 8 times the bytes with 3 bit shifts to the left of the length
186- final char [] l_ascii = new char [raw . length << 3 ];
190+ final char [] l_ascii = new char [rawLength << 3 ];
187191 /*
188192 * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
189193 * loop.
190194 */
191- for (int ii = 0 , jj = l_ascii .length - 1 ; ii < raw . length ; ii ++, jj -= 8 ) {
195+ for (int ii = 0 , jj = l_ascii .length - 1 ; ii < rawLength ; ii ++, jj -= 8 ) {
192196 for (int bits = 0 ; bits < BITS .length ; ++bits ) {
193197 if ((raw [ii ] & BITS [bits ]) == 0 ) {
194198 l_ascii [jj - bits ] = '0' ;
0 commit comments