common/src/main/java/HTTPClient/Util.java
/**
     * Creates an array of distances to speed up the search in findStr().
     * The returned array should be passed as the second argument to
     * findStr().
     *
     * @param search the search string (same as the first argument to
     *               findStr()).
     * @return an array of distances (to be passed as the second argument to
     *         findStr()).
     */
Creates an array of distances to speed up the search in findStr().
The returned array should be passed as the second argument to
findStr().

@param search the search string (same as the first argument to
findStr()).
@return an array of distances (to be passed as the second argument to
findStr()).
Creates an array of distances to speed up the search in findStr () . The returned array should be passed as the second argument to findStr () . @param search the search string ( same as the first argument to findStr () ) . @return an array of distances ( to be passed as the second argument to findStr () ) .
final static int[] compile_search(byte[] search)
    {
	int[] cmp = {0, 1, 0, 1, 0, 1};
	int   end;
	for (int idx=0; idx<search.length; idx++)
	{
	    for (end=idx+1; end<search.length; end++)
	    {
		if (search[idx] == search[end])  break;
	    }
	    if (end < search.length)
	    {
		if ((end-idx) > cmp[1])
		{
		    cmp[4] = cmp[2];
		    cmp[5] = cmp[3];
		    cmp[2] = cmp[0];
		    cmp[3] = cmp[1];
		    cmp[0] = idx;
		    cmp[1] = end - idx;
		}
		else if ((end-idx) > cmp[3])
		{
		    cmp[4] = cmp[2];
		    cmp[5] = cmp[3];
		    cmp[2] = idx;
		    cmp[3] = end - idx;
		}
		else if ((end-idx) > cmp[3])
		{
		    cmp[4] = idx;
		    cmp[5] = end - idx;
		}
	    }
	}
	cmp[1] += cmp[0];
	cmp[3] += cmp[2];
	cmp[5] += cmp[4];
	return cmp;
    }
final static int [ ] compile_search ( byte [ ] search ) { int [ ] cmp = { 0 , 1 , 0 , 1 , 0 , 1 } ; int end ; for ( int idx = 0 ; idx < search . length ; idx ++ ) { for ( end = idx + 1 ; end < search . length ; end ++ ) { if ( search [ idx ] == search [ end ] ) break ; } if ( end < search . length ) { if ( ( end - idx ) > cmp [ 1 ] ) { cmp [ 4 ] = cmp [ 2 ] ; cmp [ 5 ] = cmp [ 3 ] ; cmp [ 2 ] = cmp [ 0 ] ; cmp [ 3 ] = cmp [ 1 ] ; cmp [ 0 ] = idx ; cmp [ 1 ] = end - idx ; } else if ( ( end - idx ) > cmp [ 3 ] ) { cmp [ 4 ] = cmp [ 2 ] ; cmp [ 5 ] = cmp [ 3 ] ; cmp [ 2 ] = idx ; cmp [ 3 ] = end - idx ; } else if ( ( end - idx ) > cmp [ 3 ] ) { cmp [ 4 ] = idx ; cmp [ 5 ] = end - idx ; } } } cmp [ 1 ] += cmp [ 0 ] ; cmp [ 3 ] += cmp [ 2 ] ; cmp [ 5 ] += cmp [ 4 ] ; return cmp ; }
Creates an array of distances to speed up the search in findStr().
Creates an array of distances to speed up the search in findStr () .