diff --git a/ChangeLog.txt b/ChangeLog.txt index c3e352310c..daafe8ed51 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,22 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2016-03-30 16:10 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/gttone.c + * applied patch from Andi Jahja for new BCC versions - many thanks + + * src/rtl/strrepl.c + % added optimization code for strings longer then 1024 bytes + For very long strings it can improve replace performance 20 or + even more times. + + * src/rtl/sha2.c + * src/rtl/val.c + * src/vm/dynsym.c + * src/vm/eval.c + * src/vm/thread.c + * formatting + 2016-03-28 13:09 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com) * config/dyn.mk * config/win/mingw.mk diff --git a/src/rtl/gttone.c b/src/rtl/gttone.c index 2542eed1b5..1d99494e1f 100644 --- a/src/rtl/gttone.c +++ b/src/rtl/gttone.c @@ -83,14 +83,14 @@ static int hb_Inp9x( unsigned short int usPort ) HB_TRACE( HB_TR_DEBUG, ( "hb_Inp9x(%hu)", usPort ) ); - #if defined( __BORLANDC__ ) || defined( __DMC__ ) + #if defined( __DMC__ ) _DX = usPort; __emit__(0xEC); /* ASM IN AL, DX */ __emit__(0x32,0xE4); /* ASM XOR AH, AH */ usVal = _AX; - #elif defined( __XCC__ ) || defined( __POCC__ ) + #elif defined( __XCC__ ) || defined( __POCC__ ) || defined( __BORLANDC__ ) __asm { mov dx, usPort @@ -121,13 +121,13 @@ static int hb_Outp9x( unsigned short int usPort, unsigned short int usVal ) { HB_TRACE( HB_TR_DEBUG, ( "hb_Outp9x(%hu, %hu)", usPort, usVal ) ); - #if defined( __BORLANDC__ ) || defined( __DMC__ ) + #if defined( __DMC__ ) _DX = usPort; _AL = usVal; __emit__(0xEE); /* ASM OUT DX, AL */ - #elif defined( __XCC__ ) || defined( __POCC__ ) + #elif defined( __XCC__ ) || defined( __POCC__ ) || defined( __BORLANDC__ ) __asm { mov dx, usPort diff --git a/src/rtl/sha2.c b/src/rtl/sha2.c index 99b79ad99b..e057e316e0 100644 --- a/src/rtl/sha2.c +++ b/src/rtl/sha2.c @@ -118,7 +118,7 @@ wv[h] = t1 + t2; \ } -#define SHA512_EXP(a, b, c, d, e, f, g ,h, j) \ +#define SHA512_EXP(a, b, c, d, e, f, g, h, j) \ { \ t1 = wv[h] + SHA512_F2(wv[e]) + CH(wv[e], wv[f], wv[g]) \ + sha512_k[j] + w[j]; \ @@ -154,10 +154,10 @@ static const uint64 sha384_h0[8] = _ULL( 0xdb0c2e0d64f98fa7 ), _ULL( 0x47b5481dbefa4fa4 )}; static const uint64 sha512_h0[8] = - {_ULL( 0x6a09e667f3bcc908 ), _ULL( 0xbb67ae8584caa73b ) , - _ULL( 0x3c6ef372fe94f82b ), _ULL( 0xa54ff53a5f1d36f1 ) , - _ULL( 0x510e527fade682d1 ), _ULL( 0x9b05688c2b3e6c1f ) , - _ULL( 0x1f83d9abfb41bd6b ), _ULL( 0x5be0cd19137e2179 ) }; + {_ULL( 0x6a09e667f3bcc908 ), _ULL( 0xbb67ae8584caa73b ), + _ULL( 0x3c6ef372fe94f82b ), _ULL( 0xa54ff53a5f1d36f1 ), + _ULL( 0x510e527fade682d1 ), _ULL( 0x9b05688c2b3e6c1f ), + _ULL( 0x1f83d9abfb41bd6b ), _ULL( 0x5be0cd19137e2179 )}; static const uint32 sha256_k[64] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, diff --git a/src/rtl/strrepl.c b/src/rtl/strrepl.c index 991cbf22ec..b599ffb7fc 100644 --- a/src/rtl/strrepl.c +++ b/src/rtl/strrepl.c @@ -72,13 +72,74 @@ HB_FUNC( HB_STRREPLACE ) const char * pszText = hb_itemGetCPtr( pText ); const char * ptr; char * pszResult = NULL; + HB_SIZE * ptrOpt = NULL; + HB_BOOL fNext = HB_FALSE; HB_SIZE nDst, nSize, nPos, nAt, nSkip, nTmp; nDst = hb_itemSize( HB_IS_HASH( pSrc ) ? pSrc : pDst ); + if( nText > 1024 ) + { + ptrOpt = ( HB_SIZE * ) hb_xgrabz( 256 * sizeof( HB_SIZE ) ); + for( nAt = 0; nAt < nSrc; ++nAt ) + { + HB_UCHAR uc; + + if( pszSrc ) + uc = ( HB_UCHAR ) pszSrc[ nAt ]; + else + { + if( HB_IS_HASH( pSrc ) ) + pDst = hb_hashGetKeyAt( pSrc, nAt + 1 ); + else + pDst = hb_arrayGetItemPtr( pSrc, nAt + 1 ); + if( hb_itemGetCLen( pDst ) == 0 ) + continue; + uc = ( HB_UCHAR ) hb_itemGetCPtr( pDst )[ 0 ]; + } + if( ptrOpt[ uc ] == 0 ) + ptrOpt[ uc ] = nAt + 1; + else if( pszSrc == NULL ) + fNext = HB_TRUE; + } + } + nSize = nPos = nSkip = 0; while( nPos < nText ) { - if( pszSrc ) + if( ptrOpt ) + { + nAt = ptrOpt[ ( HB_UCHAR ) pszText[ nPos ] ]; + if( nAt == 0 || pszSrc ) + nSkip = 1; + else + { + for( ; nAt <= nSrc; ++nAt ) + { + if( HB_IS_HASH( pSrc ) ) + { + pDst = hb_hashGetKeyAt( pSrc, nAt ); + nSkip = hb_itemGetCLen( pDst ); + ptr = hb_itemGetCPtr( pDst ); + } + else + { + nSkip = hb_arrayGetCLen( pSrc, nAt ); + ptr = hb_arrayGetCPtr( pSrc, nAt ); + } + if( nSkip > 0 && nSkip <= nText - nPos && + memcmp( pszText + nPos, ptr, nSkip ) == 0 ) + break; + if( !fNext ) + nAt = nSrc; + } + if( nAt > nSrc ) + { + nAt = 0; + nSkip = 1; + } + } + } + else if( pszSrc ) { ptr = ( const char * ) memchr( pszSrc, ( HB_UCHAR ) pszText[ nPos ], nSrc ); @@ -101,7 +162,7 @@ HB_FUNC( HB_STRREPLACE ) ptr = hb_arrayGetCPtr( pSrc, nAt ); } if( nSkip > 0 && nSkip <= nText - nPos && - memcmp( pszText + nPos, ptr , nSkip ) == 0 ) + memcmp( pszText + nPos, ptr, nSkip ) == 0 ) break; } if( nAt > nSrc ) @@ -165,6 +226,8 @@ HB_FUNC( HB_STRREPLACE ) } } } + if( ptrOpt ) + hb_xfree( ptrOpt ); hb_retclen_buffer( pszResult, nSize ); } else diff --git a/src/rtl/val.c b/src/rtl/val.c index 294f5ea57a..29ccdf091b 100644 --- a/src/rtl/val.c +++ b/src/rtl/val.c @@ -84,7 +84,7 @@ HB_FUNC( HB_VAL ) HB_MAXINT lValue; double dValue; - fDbl = hb_valStrnToNum( szText, iLen, &lValue, &dValue , &iDec, &iWidth ); + fDbl = hb_valStrnToNum( szText, iLen, &lValue, &dValue, &iDec, &iWidth ); if( HB_ISNUM( 2 ) ) iLen = hb_parni( 2 ); diff --git a/src/vm/dynsym.c b/src/vm/dynsym.c index e26ae23c92..f3f3e10b04 100644 --- a/src/vm/dynsym.c +++ b/src/vm/dynsym.c @@ -721,8 +721,8 @@ HB_FUNC( __DYNSISFUN ) /* returns .T. if a symbol has a function/procedure point } HB_FUNC( __DYNSGETPRF ) /* profiler: It returns an array with a function or procedure - called and consumed times { nTimes, nTime } - , given the dynamic symbol index */ + called and consumed times { nTimes, nTime }, + given the dynamic symbol index */ { HB_STACK_TLS_PRELOAD #ifndef HB_NO_PROFILER diff --git a/src/vm/eval.c b/src/vm/eval.c index 3a8debb3dd..233e479dec 100644 --- a/src/vm/eval.c +++ b/src/vm/eval.c @@ -393,16 +393,16 @@ HB_FUNC( HB_FORNEXT ) /* nStart, nEnd | bEnd, bCode, nStep */ * hb_ExecFromArray( [, ] ) * hb_ExecFromArray( @() [, ] ) * hb_ExecFromArray( [, ] ) - * hb_ExecFromArray( , [, ] ) - * hb_ExecFromArray( , @() [, ] ) + * hb_ExecFromArray( , [, ] ) + * hb_ExecFromArray( , @() [, ] ) * or: * hb_ExecFromArray( ) * where is in one of the following format: * { [, ] } * { @() [, ] } * { [, ] } - * { , [, ] } - * { , @() [, ] } + * { , [, ] } + * { , @() [, ] } */ HB_FUNC( HB_EXECFROMARRAY ) { diff --git a/src/vm/thread.c b/src/vm/thread.c index af7ad59f94..b249fa297f 100644 --- a/src/vm/thread.c +++ b/src/vm/thread.c @@ -47,7 +47,7 @@ /* Harbour level API: - hb_threadStart( [ ,] <@sStart()> | | [, ] ) -> + hb_threadStart( [ , ] <@sStart()> | | [, ] ) -> hb_threadSelf() -> | NIL hb_threadID( [ ] ) -> hb_threadJoin( [, @ ] ) ->